devxlogo

Finding Variable Values

Finding Variable Values

Question:

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?

Answer:
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.
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist