I am try to use global variables in a queries. I understand that you have to
put a wrapper function around them, and can get it to work by defining
separate wrapper functions for each variable. I liked John's suggestion
below which seemed to be a generic wrapper using the Eval function. However,
I can't get it to work - I end up with error '2482' "...can't find the name
'gstrName' you entered in the expression." I guess I just don't understand
the Eval function well enough. Below is the code I am using to test:
Option Compare Database
Public gstrName As String
Public Function GetGlobal(varname As String) As Variant
GetGlobal = Eval(varname)
End Function
Public Sub Test()
gstrName = "Contents of gstrName"
Debug.Print GetGlobal("gstrName")
End Sub
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.