How to use Global variable in query

M

Me

I have a need to use Global variable in a query.

What's the best way to use it?

I have

select custcode, name from table1, table2
where table1.custcode=table2.custcode and
table1.custcode not in (select custcode from table3 where
country=globalvariablecountrycode)

Thank you,
-Me
 
S

SteveM

You need to create a public function and use that to return the variable.

'Variable declaration
Public globalvariablecountrycode As Integer

'Function to return variable
Public Function Get_CountryCode() As Integer
Get_CountryCode = globalvariablecountrycode
End Function

Then put Get_CountryCode() in the criteria field of you query.

Steve
 
S

SteveM

You need to create a public function and use that to return the variable.

'Variable declaration
Public globalvariablecountrycode As Integer

'Function to return variable
Public Function Get_CountryCode() As Integer
Get_CountryCode = globalvariablecountrycode
End Function

Then put Get_CountryCode() in the criteria field of you query.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top