ToolBox -

This can be caused if you forget to enclose the ID in single quotes (this applies to text IDs).  For example:

“(TPAYID = ‘01’) AND (TEMPID = “ & A2 & “)”

Should be

“(TPAYID = ‘01’) AND (TEMPID = ‘“ & A2 & “’)”