I was under the impression that TempVars could be used in SQL queries, including in the Criteria field, but this seems not to be the case.
I wrote the following test query:
and tested it with the following sub:
It gets "Error 3061. Too few parameters. Expected 1." on the Set rs statement.
If I remove the WHERE condition from the query it runs successfully.
[VarType(TempVar s!CommunityCode ) = 8, and the apparent spaces in the above code segments are not there in the original].
Am I missing something?
I wrote the following test query:
Code:
SELECT People.PersonID , Board_service_h istory.Communit yCode FROM People INNER JOIN Board_service_h istory ON People.PersonID = Board_service_h istory.PersonID WHERE (((Board_servic e_history.Commu nityCode)=[TempVars]![communitycode]));
Code:
Private Sub TestSub()
Dim db As Database, rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordse t("TestQuery" , dbOpenForwardOn ly)
Debug.Print rs!PersonID, rs!CommunityCod e
End Sub
If I remove the WHERE condition from the query it runs successfully.
[VarType(TempVar s!CommunityCode ) = 8, and the apparent spaces in the above code segments are not there in the original].
Am I missing something?
Comment