473,394 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

date Filter on form (3 months, non consecutive)

72 64KB
Hi,
would like to filter a form with a form filter, the form has 12 buttons (12 months) and would like to retrieve records depending on which button is pressed.
This filter example works, it shows records from Jan, Feb, and Apr 2021 but I don't get why it shows them all. Should't it show just one month because I used OR?


Month([DateProcessed])=1 AND Year(DateProcessed)=2021 OR Month([DateProcessed])=2 AND Year(DateProcessed)=2021 OR Month([DateProcessed])=4 AND Year(DateProcessed)=2021
Feb 5 '21 #1

✓ answered by isladogs

Add brackets around each section to clarify what the code is doing

Expand|Select|Wrap|Line Numbers
  1. (Month([DateProcessed])=1 AND Year(DateProcessed)=2021) 
  2. OR (Month([DateProcessed])=2 AND Year(DateProcessed)=2021) 
  3. OR (Month([DateProcessed])=4 AND Year(DateProcessed)=2021)
Now can you see why it will show results for each of the months listed

2 1806
isladogs
455 Expert Mod 256MB
Add brackets around each section to clarify what the code is doing

Expand|Select|Wrap|Line Numbers
  1. (Month([DateProcessed])=1 AND Year(DateProcessed)=2021) 
  2. OR (Month([DateProcessed])=2 AND Year(DateProcessed)=2021) 
  3. OR (Month([DateProcessed])=4 AND Year(DateProcessed)=2021)
Now can you see why it will show results for each of the months listed
Feb 5 '21 #2
NeoPa
32,556 Expert Mod 16PB
Hi Neruda.

I think what you're missing in your appreciation of how the SQL WHERE clause works is that it :
  1. ISN'T - an overall description of the logic of which records to get such as :
    Get me all records WHERE A AND/OR all records WHERE B.
  2. IS - a description of the logic for each record :
    Get me all records WHERE (For each record) A AND/OR B.
In your case, assuming I were to choose months Jan & Apr (Forgetting about Year for now.), then I would choose every record which was Jan AND every record which was Apr, because - at an individual record level - Jan OR Apr evaluated to True.

Does that make the logic clearer?
Feb 6 '21 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: khalid_uk | last post by:
hi can anyone please show me how to put current date in form (drop down) and it should gives the user an error if the want to choose an invalid dates (holidays and past days) and current month and...
3
by: Nathan Bloomfield | last post by:
I am having difficulty filtering dates for a report. I have written the following code on a popup form which works with regular date fields , however, I am now trying to apply the same concept to...
6
by: Tony Miller | last post by:
All I have an aggregate query using the function Month & Year on a datereceived field ie: TheYear: Year() TheMonth: Month() These are the group by fields to give me a Count on another field by...
1
by: Ronniesss1 | last post by:
I have a table called RescheduleIns and another called Shop Complete Table that are opened together on another form called fAll Shop Orders. On this form, all the Shop Complete Table data is...
7
by: Mpho Pole | last post by:
Hi I have a form that feeds filter parameters to a report. My problem stems from using date parameters to filter.My code is as follows: If IsNull(Me.Date.Value) And IsNull(Me.EndDate.Value) Then ...
1
by: mrityunjay11 | last post by:
i want a date selection form in jsp and that variable should be caught in servlet that is how to catch date varible in my servlet. thanks a lot Regards mrityunjay singh
1
by: tmcjunkin | last post by:
I'm trying to back into this project by defining what the user needs to see when they open a form. I'm between beginner and intermediate with vba, but have been using access for years. When the...
5
by: ahd2008 | last post by:
I have a form that pop up on the sessions form. i use the below code to filter the sessions form by the strat date of the course but it seems it is not giving any result. I get only empty fields ...
3
by: dylankirs | last post by:
Hi. Apologies for any incorrect/off technical lingo. Fairly new to Access and would appreciate any help! I'm trying to create a command button that will filter form records based on an already...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.