Hello statmanbp
Please tell us your name because we're all on first name terms here :)
It is much better to create a filter that compares a date field with computed constants, rather than comparing a value computed from the date field with a constant. The former uses the index to remove the non-conformant candidates, while the latter requires every record to be processed.
So what we require in this case is two expressions that return constants for (a) the first day of the previous month and (b) the first day of the current month. The filter expression is then:
[DateField] >= (a) AND [DateField] < (b)
For (a), use DateSerial( Year(Date()), Month(Date())-1, 1)
For (b), use DateSerial( Year(Date()), Month(Date()), 1)
Your filter expression is then:
([Test_Date] >= DateSerial( Year(Date()), Month(Date())-1, 1)) AND ([Test_Date < DateSerial( Year(Date()), Month(Date()), 1))
Good luck!
Graham
_____
Graham Mandeno
Microsoft Access MVP 1996 - 2015
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Saturday, 3 January 2015 07:10
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Previous Month Filter
I have a filter that calls for the previous month
"
Year([Test_Date]) = Year(Now()) And Month([Test_Date]) = Month(Now()-1)
"
did not think about January of the next year. Any help would be appreciated.
[Non-text portions of this message have been removed]
Posted by: "Graham Mandeno" <graham@mandeno.com>
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (5) |
Tidak ada komentar:
Posting Komentar