Can you refer to a variable in a hard query?

  • Thread starter Thread starter Dean Spiker
  • Start date Start date
D

Dean Spiker

Is it possible to use the value of a variable in an
expression that resides in a hard query? What I mean
by "hard query" is a query that resides in the Queries
tab of the database window. I know you can use a
variable in an expression in a query built on the fly
using code, but I really need to use a variable in a hard
query. Does anyone know how to do this? Thanks so much!
 
Create a function to return the value of the variable. Add the function
name to the query.


Code:

dim gintXYZ as integer

Function GetGlobalVariableXYZ() as integer

GetGlobalVariableXYZ = gintXYZ

End Function


Query:

Select * from tblStuff WHERE tblStuff.xyz = GetGlobalVariableXYZ

--
HTH,

Steve Clark, Access MVP
FMS, Inc.
Professional Solutions Group
http://www.FMSInc.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Is your Access database too slow?
Are you ready to upgrade to SQL Server?
Contact us for optimization and/or upsizing!
http://www.FMSInc.com/consulting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
Back
Top