Date Filter Access Macro

F

FSCK!

Hello All -

I have a db with a drop down field which automatically runs a
predefined macro based on the folowing selections:

"All";"Today";"This Week";"Last Week";"This Month";"Last Month";

I have added an additional selection with corresponding macro for "This
Year" as follows:

(Year([Opened Date])=Year(Date()) And Year([Opened Date])=Year(Date()))

My problem is, I am now trying to add an addional entry named "Last
Year" and I am having trouble. Here is how I am doing it:

(Year([Opened Date])=Year(Date()) And Year([Opened
Date])=(Year(Date())-1))

Could someone be so kind as to tell me what I am doing wrong with the
above? To test this, I set my clock ahead one year and was expecting
the macro to show me inputs for 2006, however, nothing shows.

Many thanks in advance
 
S

Steve Schapel

FSCK,

I do not understand why the Criteria is being repeated twice.
(Year([Opened Date])=Year(Date()) And Year([Opened Date])=Year(Date()))
is equivalent to simply...
Year([Opened Date])=Year(Date())

As for the "last year" criteria, this doesn't work.
(Year([Opened Date])=Year(Date()) And Year([Opened Date])=(Year(Date())-1))
is saying the opened date is both this year and last year at the same
time, which is impossible for a date to simultaneously be in two
different years. Try it just like this...
Year([Opened Date])=Year(Date())-1

By the way, this doesn't appear to have anything to do with macros.
 
F

FSCK!

many thanks Steve, this worked wonderfully. I am still learning this,
so I thank you for your insight.


Steve said:
FSCK,

I do not understand why the Criteria is being repeated twice.
(Year([Opened Date])=Year(Date()) And Year([Opened Date])=Year(Date()))
is equivalent to simply...
Year([Opened Date])=Year(Date())

As for the "last year" criteria, this doesn't work.
(Year([Opened Date])=Year(Date()) And Year([Opened Date])=(Year(Date())-1))
is saying the opened date is both this year and last year at the same
time, which is impossible for a date to simultaneously be in two
different years. Try it just like this...
Year([Opened Date])=Year(Date())-1

By the way, this doesn't appear to have anything to do with macros.

--
Steve Schapel, Microsoft Access MVP


FSCK! said:
Hello All -

I have a db with a drop down field which automatically runs a
predefined macro based on the folowing selections:

"All";"Today";"This Week";"Last Week";"This Month";"Last Month";

I have added an additional selection with corresponding macro for "This
Year" as follows:

(Year([Opened Date])=Year(Date()) And Year([Opened Date])=Year(Date()))

My problem is, I am now trying to add an addional entry named "Last
Year" and I am having trouble. Here is how I am doing it:

(Year([Opened Date])=Year(Date()) And Year([Opened
Date])=(Year(Date())-1))

Could someone be so kind as to tell me what I am doing wrong with the
above? To test this, I set my clock ahead one year and was expecting
the macro to show me inputs for 2006, however, nothing shows.

Many thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Access Formula For Dates 4
Age 9
Calculate Years of Service 11
Using DatePart to find last years data 3
Macro Stoped Working 2
date value expression and syntax 1
DATE 4
John W. Vinson...continued help please 4

Top