• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 699
  • Last Modified:

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?
0
HyperBPP
Asked:
HyperBPP
  • 3
  • 2
1 Solution
 
Dale FyeCommented:
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
 
HyperBPPAuthor Commented:
When I put that in the query it gives me a missing operator syntax error.
0
 
Dale FyeCommented:
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 FyeCommented:
glad that worked for you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now