Link to home
Start Free TrialLog in
Avatar of Keef4000
Keef4000

asked on

Access question

Is their an automatic function like "today" for something like "Previous Month"

We run reports all the time and we have to constantly put in between "1-1-12 and 1-31-12" It would be nice if there was something like "current month" or "previous month" sort of thing.
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Keef4000
Keef4000

ASKER

Thank you that was simple enough
I generally do this in the form of a combo box, where I display the month names, for maybe the last 3 or 4 months.

I use a table (tbl_Numbers) that has a single field (intNumber) and 10 records (0-9).  Then, I create a query that looks like:

SELECT Format(DateSerial(Year(Date()), Month(Date()) - intNumber, 1), "mmm")
             , DateSerial(Year(Date()), Month(Date()) - intNumber, 1) as StartDate
             , DateSerial(Year(Date()), Month(Date()) - intNumber + 1, 0) as EndDate
FROM tbl_Numbers
ORDER BY intNumber
By doing the combo box, you can hide the start and end dates by setting the column widths to 0, but can refer to those columns in your code.

Note, that if you refer to these combo columns in code, you probably need to wrap them in the cDate( ) function to ensure they are treated as dates and not as text:

cDate(me.comboDates.column(1)) or cDate(me.comboDates.column(2))