Temp Variable for Criteria in Query Design

  • Thread starter Chris F via AccessMonster.com
  • Start date
C

Chris F via AccessMonster.com

Is there a way to reference a set Temp. Variable in Access 07's query design
under criteria. In VBA, I can call a temp variable and use it in a query
built at run time, but I am looking to use this query without having to hard
code it.

Is this possible?

Any thoughts would be greatly appreciated.
 
Z

zofficedepot

Is there a way to reference a set Temp. Variable in Access 07's query design
under criteria. In VBA, I can call a temp variable and use it in a query
built at run time, but I am looking to use this query without having to hard
code it.

Is this possible?

Any thoughts would be greatly appreciated.

There are limitations (which I don't recall right away), but you can
use a variable in the following fashion. For a Table1 that has the
sole field fname, to get a list of unique field values:

SELECT [foo] AS Expr1, fname
FROM Table1
GROUP BY [foo], fname
HAVING fname=[foo];

When you run this in Access (97-2003 at least) it will prompt you for
the value, and use what you type in as the criteria. Is that what you
meant? (Note, I included [foo] in the SELECT clause but it can be
removed here)

BTW, if you like this, extending it for wildcards can be rewarding:
Like "*" & [foo] & "*"
I can repeatedly "search" that way - very fast - because I don't have
to create new queries for different criteria.
 
Top