Code to open report with current month data only

graceusguide

New member
Local time
Today, 07:44
Joined
Jan 10, 2010
Messages
6
Hi,

I am trying to find the code so I can correctly filter a report so that when a button is pressed on myform the report shows all records that are current month to date records. eg. today would show all records in October 2012. Does that make sense?
 
Look at "DemoCurrentMonthReportA2003.mdb" (attachment, zip).
Look at Table1, Query1, Form1, Report1. Open form and try.
But, if you want year 2012 only, you have to incluede the year in
query, and in form.
 

Attachments

Hi,

I assume that your report is based on a query, therefore in your query using a new blank columns enter the following:

Field Row: Month([dtmDateStamp])
Criteria Row: Month(Now())
Show Row: uncheck the box so that this column doesn't display in your table unless you want it to in which case don't uncheck it.

This will ensure that only the current month data is displayed.

in another blank column enter the following:

Field Row: Year([dtmDateStamp])
Criteria Row: Year(Now())
Show Row: uncheck the box so that this column doesn't display in your table unless you want it to in which case don't uncheck it.

This will ensure that only the current year data is displayed.

Together the above two will ensure that only the current month and year will be displayed.

This method may not be considered the best by some of our more accomplished access worriers, but it's a method I've always used and it has always worked fine for me.

I hope this has been of some help.

Regards

John

Edit:

dtmDateStamp is the name of my date field this should be replaced with your date field name.

John
 

Users who are viewing this thread

Back
Top Bottom