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

Using a variable in a select query? 1

Status
Not open for further replies.

dandough

Technical User
Dec 6, 2003
12
CH
Hi All,

I would like to get a string from a list box on a form and assign it to a variable. Then use that variable in the 3 select queries I've already created which are using a parameter at the moment. A heads up in the right direction would be appreciated.


Thanks,
Dan
 
You could use a global functions and variable to set and read the value:

Dim gstrVar as String

Function SetVariable(pstrVar as String)
gstrVar = pstrVar
End Function

Function GetVariable() as String
GetVariable=gstrVar
End Function

Call the set function after update of the list box and use the get function in the criteria of the query.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Hi Duane,

Where on the query grid would I enter the getVal function? The function is picking up the string as shown through a message box but the query is coming up empty. I put the getVal() function where the parameter used to be without the brackets.

Thanks for your time,

Dan
 
Place the GetVal() function in the criteria of the query.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top