K
Kari
I am trying to use a Global Variable as a criteria in a query. I learned how
to do that for a string variable on this discussion board (see below--Thanks
John W. Vinson!). However, it doesn't work for a number (double) variable.
The function works fine (as tested from another bit of code), but it doesn't
work in the query. The query builder keeps putting quotes around the
variable name and coming up with a "data type mismatch" error. Is my syntax
wrong? Should my variable and GetGlobal function be strings even though my
column (in the query) is a double?
Help!
Kari
[Note: I'm typing: GetGlobal(POforReport)
in my query, since both POforReport and the column in the query are doubles]
to do that for a string variable on this discussion board (see below--Thanks
John W. Vinson!). However, it doesn't work for a number (double) variable.
The function works fine (as tested from another bit of code), but it doesn't
work in the query. The query builder keeps putting quotes around the
variable name and coming up with a "data type mismatch" error. Is my syntax
wrong? Should my variable and GetGlobal function be strings even though my
column (in the query) is a double?
Help!
Kari
Queries don't have direct access to VBA variables, global or not. You
need to write a dumb little wrapper function:
Public Function GetGlobal(varname as string) As Variant
GetGlobal = Eval(varname)
End Function
If the variable is named glUsername, you'ld put
GetGlobal("glUsername")
in the Criteria line of the query.
[Note: I'm typing: GetGlobal(POforReport)
in my query, since both POforReport and the column in the query are doubles]