Go Back   Access World Forums > Microsoft Access Discussion > Macros

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-17-2017, 12:42 PM   #1
cricketbird
Newly Registered User
 
Join Date: Jun 2013
Location: Tampa, Florida
Posts: 53
Thanks: 17
Thanked 1 Time in 1 Post
cricketbird is on a distinguished road
SetFilter only works for one conditional, not two

I basically want a simple form that I can filter by three variables (SUPPLIER, FOOD, ANALYSIS). There are three comboboxes that let you pick from our short lists of suppliers, foods, and analyses, and a subform based on a query of those tables. This is a webform where I can't refer to the comboboxes in my query, so I am using localvars in a macro instead.

I have a search button that sets three local variables (my_SUPPID, my_ANALYSISID, my_FOODID) from the three combo boxes.

Code:
SetLocalVar
Name my_SUPPID
Expression = [cboSUPPS]
I then SetFilter with:
Code:
SetFilter
Where Condition = ([SUPPID]=[LocalVars]![my_SUPPID]) And ([FOODID]=[LocalVars]![my_FOODID])
Control Name subf_Analyses
and it works as expected.

However, if I add a third criteria for the remaining combo box:
Code:
 Where Condition = ([SUPPID]=[LocalVars]![my_SUPPID]) And ([FOODID]=[LocalVars]![my_FOODID]) And ([ANALYSISID]=[LocalVars]![my_ANALYSISID])
I get no records. The button works for any of the combinations of two criteria, but fails when I add a third.

I've debugged the results of my localvars and they are as expected.

Any help would be appreciated!
CB

cricketbird is offline   Reply With Quote
Old 05-17-2017, 01:10 PM   #2
ridders
Registered User
 
Join Date: Jan 2017
Location: Somerset, England
Posts: 521
Thanks: 19
Thanked 117 Times in 115 Posts
ridders is on a distinguished road
Re: SetFilter only works for one conditional, not two

Just a guess but try an extra overall pair of brackets:

Code:
 Where Condition = (([SUPPID]=[LocalVars]![my_SUPPID]) And ([FOODID]=[LocalVars]![my_FOODID]) And ([ANALYSISID]=[LocalVars]![my_ANALYSISID]))
__________________
Colin
(Access 2010 /2016, SQL Server, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
)


If this answer has helped, please click the Thumbs up symbol OR tip the scales on the left for me!
ridders is offline   Reply With Quote
Old 05-17-2017, 04:41 PM   #3
cricketbird
Newly Registered User
 
Join Date: Jun 2013
Location: Tampa, Florida
Posts: 53
Thanks: 17
Thanked 1 Time in 1 Post
cricketbird is on a distinguished road
Re: SetFilter only works for one conditional, not two

The functional solution was indeed parentheses, but somehow not what you suggested.

((BOOL_A) AND (BOOL_B) AND (BOOL_C)) did not work.
However
((BOOL_A) AND (BOOL_B)) AND (BOOL_C) did. Scratching my head over this one still. At any rate, it works! Logically, these are the same, no? And, in fact, should be the same without any external parentheses (which is how I originally had it).

I feel there is some underlying problem - either a bug in my setup (most likely) or a bug in the system (possible). At any rate, it works.

cricketbird is offline   Reply With Quote
Reply

Tags
macro , setfilter

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting not works on Text box juan96 Reports 2 06-22-2016 12:38 AM
Copy After works only for the first time and works again after reopening the Access D baba Modules & VBA 3 06-21-2015 05:28 PM
SetFilter Macro johannaellamay Macros 11 03-16-2015 10:14 PM
Criteria: OR works, AND does not works Surka Queries 6 07-15-2014 01:22 PM
Conditional formatting only works on mouse over Graeme Forms 8 01-02-2013 07:22 AM




All times are GMT -8. The time now is 05:45 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World