A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Temp Variable for Criteria in Query Design



 
 
Thread Tools Display Modes
  #1  
Old June 19th, 2008, 09:26 PM posted to microsoft.public.access.queries
Chris f via AccessMonster.com
external usenet poster
 
Posts: 7
Default Temp Variable for Criteria in Query Design

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.

--
Message posted via http://www.accessmonster.com

  #2  
Old June 20th, 2008, 01:35 AM posted to microsoft.public.access.queries
[email protected]
external usenet poster
 
Posts: 8
Default Temp Variable for Criteria in Query Design

On Jun 19, 3:26 pm, "Chris F via AccessMonster.com" u19217@uwe
wrote:
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.

--
Message posted viahttp://www.accessmonster.com


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.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.