Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Help with SQL
Dan Jackson 
            
3 years ago
Hi Guys,

Can someone help me with this SQL?

The below code generates no errors. The first two lines work but the Year and Month aren't filtering. Note these aren't date values, they're numeric.

============================================================
Here's the SQL Version (~ Previous Code Working Fine, Omitted):

" ~ WHERE Telesales = forms![figuresF]![combo_FilterTelesales]" & _
" OR Chaser = forms![figuresF]![combo_FilterTelesales]" & _
" AND FilterYearAppt = Forms![FiguresF]![Combo_FilterYear] " & _
" OR FilterYearChase = Forms![FiguresF]![Combo_FilterYear]" & _
" AND FilterMonthAppt = Forms![FiguresF]![Combo_FilterMonth]" & _
" OR FilterMonthChase = Forms![FiguresF]![Combo_FilterMonth];"


=============================================================

English Version:

Combo_FilterTelesales - Filter Fields Telesales OR Chaser
AND
Combo_FilterYear - Filter Fields FilterYearAppt OR FilterYearAppt
AND
Combo_FilterMonth - Filter Fields FilterMonthAppt OR FilterMonthAppt

Many Many Many Thanks!
Alex Hedley  @Reply  
           
3 years ago
If you hardcode values first does it work?
Scott Axton  @Reply  
        
3 years ago
It looks to me like you need to apply parentheses so that the clause is appropriately applied correctly.
If for no other reason than readability.

Kevin Robertson  @Reply  
          
3 years ago
There are a lot of ANDs and ORs. I would use parentheses.

Perhaps something like this:

" ~ WHERE (Telesales = forms![figuresF]![combo_FilterTelesales]" & _
" OR Chaser = forms![figuresF]![combo_FilterTelesales])" & _
" AND (FilterYearAppt = Forms![FiguresF]![Combo_FilterYear] " & _
" OR FilterYearChase = Forms![FiguresF]![Combo_FilterYear])" & _
" AND (FilterMonthAppt = Forms![FiguresF]![Combo_FilterMonth]" & _
" OR FilterMonthChase = Forms![FiguresF]![Combo_FilterMonth]);"


Note: I haven't tested this in Access so may need tweaking.
Dan Jackson OP  @Reply  
            
3 years ago
Thanks guys. Kevins method worked BUT i went and added a third part and that third part doesn't work - it isn't filtering essentially.

I'm 99.9% there and it looks amazing. The form is dcounting 7 "types" of records, then looking up the multiplication factor and calculating accordingly. Just one of the  factors isn't quite working. FYI, it's a list box which alters its columns based on buttons on screen.

I've separated the sections for easy readability and the bold one is the one i'm having problems with (The one i added after your post)

    RS = RS & " FROM FiguresQ WHERE (Telesales = Forms![FiguresF]![Combo_FilterTelesales]" & _
                        " OR Chaser = Forms![FiguresF]![Combo_FilterTelesales])" & _
                        " AND (FilterYearAppt = Forms![FiguresF]![Combo_FilterYear] " & _
                        " OR FilterYearChase = Forms![FiguresF]![Combo_FilterYear]" & _
                        " OR FilterYearLOA = Forms![FiguresF]![Combo_FilterYear])" & _
                        " AND (FilterMonthAppt = Forms![FiguresF]![Combo_FilterMonth]" & _
                        " OR FilterMonthChase = Forms![FiguresF]![Combo_FilterMonth]" & _
                        " OR FilterMonthLOA = Forms![FiguresF]![Combo_FilterMonth]);"


Its end of the day for me and i don't work Friday (And we brits get the Monday off to coronate our king) so i'll take a look with fresh eyes next week.

Really appreciate the help. I'll be sure to show off with screenshots when i'm done :)
Kevin Yip  @Reply  
     
3 years ago
Hi Dan, the parts of your criteria that have multiple Or conditions will evaluate to True if *any* of the Or conditions is true.  For instance, all the expressions below produce the same result, True:

     True And (False Or False Or True)
     True And (False Or True Or False)
     True And (True Or False Or False)
     True And (False Or True Or True)

None of the above Or conditions would be what I would call "decisive" -- meaning, whether they are true or not won't matter, as long as one of the other Or conditions is true.  If you want a condition to be "decisive", it needs to be an And condition.

For instance:

     A And (B And (C Or D))

In this case, both A and B are "decisive" -- if A is false, the whole expression is false; if B is false, the whole expression is false.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/7/2026 2:38:30 AM. PLT: 1s