The SQL statment is a String, so you use String Contaction rulues and operators.
You pass the variable to the SQL statment the same way you put variables values in a string.
Just keep in mind that if the variable type is a string you must use quotation marks ('), or youll will get an run time error.
Then the correct code would be:
(assuming data1 is a datacontrol)
'**** For Numbers ****
data1.recordsource="(shape{SELECT * FROM table WHERE fieldname=" & temp &")}"
data1.refresh'**** For STRINGS ****
data1.recordsource="(shape{SELECT * FROM table WHERE fieldname='" & temp &"')}"
data1.refresh
'**** For DATES ****
data1.recordsource="(shape{SELECT * FROM table WHERE fieldname=#" & temp &"#)}"
data1.refresh