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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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(Dat e()), 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
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(Dat
, 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))
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
ASKER