How to use Global variable in query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
Back
Top