Assign with SQL Statement

kermit

Registered User.
Local time
Today, 13:34
Joined
Dec 20, 2002
Messages
12
Is it possible to take a SQL statement and assign it straight to a variable? I have tried a few different ways and it doesnt seem to work. Heres what i mean:

Dim myVar as string

myVar = "Select field from table where field1 = Value";

thanks for your help-

-D Frog.
 
Simply put, no!

A query returns records; not a value.
 
You can store and SQL statement as a string in a variable. What you have is a variable that is equal to text.

In order to get the Recordset you will need to use the DAO/ADO/RDO/Array methods to return the records associated with the SQL String.

basically you stopped short of your goal, but at least you are on the right road :D
 
If you are looking for ONE value from a table/query, you could use DLOOKUP, but if you are doing a lot of processing (looping through a recordset as an example) you don't want to use it, it is to slow.
 

Users who are viewing this thread

Back
Top Bottom