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 » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Set Query Criteria thru Function



 
 
Thread Tools Display Modes
  #1  
Old May 26th, 2010, 05:48 PM posted to microsoft.public.access.forms
Abe Katz
external usenet poster
 
Posts: 43
Default Set Query Criteria thru Function

Hi,
I'm setting a query criteria thru a function, i.e. V1="RED": SetCriteria(V1)
(setting global variable) and then I use in the Query Criteria another
function to get the global variable i.e. GetCriteria().
It works fine.
Now I want to set a criteria with multiple selections i.e.. V2="BLUE": V3=V1
& " or " & V2
and SetCriteria(V3) but it doesn't work.
I tried with adding (wrap around with) quotes to V1 and V2 but it doesn't
work.
I can make V3 looks like this ""RED" or "BLUE"". or "RED or BLUE"
Any suggestions?
Thanks



  #2  
Old May 26th, 2010, 07:41 PM posted to microsoft.public.access.forms
PieterLinden via AccessMonster.com
external usenet poster
 
Posts: 307
Default Set Query Criteria thru Function

Abe Katz wrote:
Hi,
I'm setting a query criteria thru a function, i.e. V1="RED": SetCriteria(V1)
(setting global variable) and then I use in the Query Criteria another
function to get the global variable i.e. GetCriteria().
It works fine.
Now I want to set a criteria with multiple selections i.e.. V2="BLUE": V3=V1
& " or " & V2
and SetCriteria(V3) but it doesn't work.
I tried with adding (wrap around with) quotes to V1 and V2 but it doesn't
work.
I can make V3 looks like this ""RED" or "BLUE"". or "RED or BLUE"
Any suggestions?
Thanks


global variables... shudder
You could do this with a form-level variable... Why not just save the core
structure of the SQL statement in a querydef and then append the WHERE and
ORDER BY clauses at runtime? Just save the original (unmodified) .SQL
property of the query into a string variable, modify the SQL property and run
the query, and then revert the SQL property back to the saved variable. You
can do all this through your form... should be simple...

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

  #3  
Old May 27th, 2010, 06:25 PM posted to microsoft.public.access.forms
Abe Katz
external usenet poster
 
Posts: 43
Default Set Query Criteria thru Function

Thanks for your response,
Can you give me an example how to do this.
Thanks

"PieterLinden via AccessMonster.com" u49887@uwe wrote in message
news:a897d397502d7@uwe...
Abe Katz wrote:
Hi,
I'm setting a query criteria thru a function, i.e. V1="RED":
SetCriteria(V1)
(setting global variable) and then I use in the Query Criteria another
function to get the global variable i.e. GetCriteria().
It works fine.
Now I want to set a criteria with multiple selections i.e.. V2="BLUE":
V3=V1
& " or " & V2
and SetCriteria(V3) but it doesn't work.
I tried with adding (wrap around with) quotes to V1 and V2 but it doesn't
work.
I can make V3 looks like this ""RED" or "BLUE"". or "RED or BLUE"
Any suggestions?
Thanks


global variables... shudder
You could do this with a form-level variable... Why not just save the core
structure of the SQL statement in a querydef and then append the WHERE and
ORDER BY clauses at runtime? Just save the original (unmodified) .SQL
property of the query into a string variable, modify the SQL property and
run
the query, and then revert the SQL property back to the saved variable.
You
can do all this through your form... should be simple...

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



 




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 07:08 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.