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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing an SQL result into a variable

Status
Not open for further replies.

carleto

Technical User
Nov 1, 2003
7
CA
I was wondering the best way to store a SQL result into a variable. I have a table that will always have just one field with one record. I want to store that result into a variable in a sub procedure. I thought I would be able to do the following:

Dim temp As String

SQL = "SELECT UserName INTO " & temp & " FROM tblUserName;"

DoCmd.RunSQL SQL

But this does not seem to work.

I have also considered using a record set but how do you store into a variable using a recordset?
 
carleto,

Have you tried using DLookUp???? There are examples in the help text....[reading]



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top