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!

Access 2000 VBA 1

Status
Not open for further replies.

DWSwaim

Programmer
Jan 22, 2004
4
US
I need to assign a value from a temp query field into a string variable to be used in the sub. Any ideas? Here’s the jist of my code:

Set dbsDatabase = CodeDb
strSQL = "SELECT Recruitment_Location_Name FROM [Recruitment Locations] WHERE [Recruitment_Location_ID] = intLocation"
Set qdfstrTemp = dbsDatabase.CreateQueryDef(strQname, strSQL)

‘I tried the next line (and several like it) to get the value
strLocation = [Temp_Location_Query].Recruitment_Location_Name
DoCmd.DeleteObject acQuery, strQname
Set dbsDatabase = Nothing

Thanks
Darrell
 
Have you tried ...

strLocation = qdfstrTemp!Recruitment_Location_Name

Tiny


Perfection is Everything
If it worked first time we wont be here!
 
Hi DWSwaim,

When you do CreateQueryDef you are creating a Query, not running it.

If you just want a single value from a table, use the DLookup Function ..

Code:
strLocation = DLookup("[Recruitment_Location_Name]","[Recruitment Locations]","[Recruitment_Location_ID] = " & intLocation)

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
strLocation = qdfstrTemp!Recruitment_Location_Name
Did not work but I may have some other coding to do for it.

strLocation = DLookup("[Recruitment_Location_Name]","[Recruitment Locations]","[Recruitment_Location_ID] = " & intLocation)
worked as is....

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top