Finding Variable Values

Finding Variable Values


Data1.Recordset.FindFirst “LastName = ‘Quayle'”
Ok that works fine. Why can’t I:
Data1.Recordset.FindFirst “LastName = VarLN”
where VarLN is a variable which the user has just provided? I get error 3070, “Can’t bind VarLN”. What’s wrong here?

You can’t embed a variable name within quotes. Here’s how your line should look:

Data1.Recordset.FindFirst “LastName = ‘” & VarLN & “‘”
You have to remember to put the single quotes around the string variable value, so that when the variable’s value is inserted, it is correctly formatted.


Share the Post: