Global Variables as Query criteria?

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
 
S

Sasha

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
 
M

[MVP] S. Clark

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

Ask a Question

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.

Ask a Question

Top