Using Global Vars in queries

  • Thread starter Thread starter greghedberg
  • Start date Start date
G

greghedberg

Is it possible to reference a global Variable defined in a
module within a query.
 
Yes, indirectly through a function.

For example, if you had a global variable defined in a module that looked
something like this:

Public YourGlobalVariable As String

you might create a function in the same function that looks something like
this:

Public Function YourGlobalVariableValue() As String
YourGlobalVariableValue = YourGlobalVariable
End Function

You might then use this in a query like this:

SELECT
[Your Table].*
FROM
[Your Table]
WHERE
[Your Table].[Your Text Field] = YourGlobalVariableValue()
 
Not directly, but you can create a public function that returns the value of
the variable, and use the function in the query.
 
Back
Top