Passing query parameters in Access Query

I'm working with VBA in Access 2013.  I have a pre-defined query (huge query).  I'm calling the query with the DoCmd.openQuery. I have a couple params that I would like to be variable in the WHERE clause.  Is there a way to pass params in the call or have the query use like a global TemVars! variable?
LVL 6
HyperBPPAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Developing Solutions LLCCommented:
Yes, you can set and use tempvars.  Syntax would look something like:

Where isnull([tempvars]![yourvar]) or([yourfield] = nz([tempvars]![yourvar], 0))

This assumes that the field [yourfield] is numeric and has no values equal to zero.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HyperBPPAuthor Commented:
When I put that in the query it gives me a missing operator syntax error.
0
Dale FyeOwner, Developing Solutions LLCCommented:
did the change the name of your field?  Why don't you post what you have and tell me what field you want to query by and I'll see what I can do.
0
HyperBPPAuthor Commented:
Actually, this did work.  Not sure what I was doing wrong before.  Thanks!
0
Dale FyeOwner, Developing Solutions LLCCommented:
glad that worked for you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.