Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

running date query show

Forum home » Delegate support and help forum » Microsoft Access Training and help » Running a date query to show records from the previous month

Running a date query to show records from the previous month

ResolvedVersion 2007

Jamie has attended:
Access Introduction course
Access Intermediate course

Running a date query to show records from the previous month

I have a table which I add records to daily, one of the fields is a date field.
I want to run a query that returns all the records from the previous month. According to the Access help I should be using this criteria:
Year(Date())*12+DatePart("m",Date())-1
However, it's not returning any results.
Please help!
Cheers,
Jamie

RE: Running a date query to show records from the previous month

Hi Jamie, thanks for your query. Difficult to advise on this one without seeing the criteria in context with the query and your data. However, why not try a parameter query?

Try this criteria on the date field

"Between [Enter Start Date] And [Enter End Date]"

...which should prompt the user to enter the dates, and pull out the relevant information or alternatively, or if you want it to happen automatically:

Between Date( ) And DateAdd("M", -1, Date( ))

Hope this helps,

Anthony

Fri 18 Feb 2011: Automatically marked as resolved.

Access tip:

Prefixed Autonumbering

When using Date Type = Autonumber as a primary key, clients may require autonumbering to be prefixed with a letter.

For example, P001, where P is the prefixed letter

Instructions
Step 1. Create Field Name
Step 2. Set Data Type to Autonumber
Step 3. Within Field Property General tabsheet,
enter Format property as [backslash]P000



View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.