Global Variables as Query criteria?

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

Is it possible to use a global variable as a selection
criteria in a query? I want to delect a date (from a combo
box on a form) assign that value to a global variable then
run a query with that valus (With the form going away) I
know I can get the value from the form to the query but I
run into problems if I make the form go away to expose the
query.

Thanks.

Rick
 
Hi Rick,

you can do this by writing the whole thing in VBA behind
the form.
for the SQL string, put the global variable in your
criteria. I usually cheat and write the query in the
designer as I need it, then switch to SQL view and grab
the SQL string from there.

When you paste the sql string into your code remember to
put it in quotes, except for the global variable. so you
would have "Select blah from tblblah where blah= " &
globalvarialbe & ";"

Hope that helped.

Sasha
 
Make the global variable.
Make a global proc that returns the variable
Call the global proc from the query.

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