Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Results

Status
Not open for further replies.

khansen97

Programmer
Oct 14, 2003
60
US
Does anybody have any code that I can use to put the results of a query in a variable in MS Access?

I have an SQL statement that gives me a field. I want to get that field into a variable, but I am really struggling.

Any help would be great.

thanks
 
If you have a field, then you should be able to do.

[tt]MyVariable = rst!SomeField[/tt]

- or - if more complex, show what you have and elaborate on what you want to do.

Roy-Vidar
 
Do you want something similar to Select @Var = Field1 in SQL server?

If you are sure the SQL query will return only one row
MyVar=Dlookup("MyField","MyQuery","MyCondition") should do

For more than one row returned the value returned is not defined. You will have to open a recordset and assign to a variable as Roy suggested

Best of luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top