Report based on selected dates

S

sive

Hi. I'm new to access. I have a table with 8 fields. one of which is a date.
The table will always be added to each day (the date will change with each
entry). I need to produce a report which allows the user to select a range of
dates. eg: a report from 1/4/07 to 7/4/07. How does the user select the date
range?
Thank you. Help is appreciated.
 
C

Carl Rapson

There are two basic ways: put the date range into the report's RecordSource
so that the user is prompted when the report runs; something like:

"SELECT * FROM
WHERE [DateField] BETWEEN [Enter Start Date:] AND
[Enter End Date:]"

A better (in my opinion) way is to use two textbox controls on a form to
input the start and end dates, and then pass the date range to the report in
the WhereCondition parameter of OpenReport:

DoCmd.OpenReport "MyReport",,,"[DateField] Between #" & txtStartDate & "#
And #" & txtEndDate & "#"

The DoCmd statement should be all on one line.

Carl Rapson
 
S

sive

thankyou Carl. I'll have a go!

Carl Rapson said:
There are two basic ways: put the date range into the report's RecordSource
so that the user is prompted when the report runs; something like:

"SELECT * FROM
WHERE [DateField] BETWEEN [Enter Start Date:] AND
[Enter End Date:]"

A better (in my opinion) way is to use two textbox controls on a form to
input the start and end dates, and then pass the date range to the report in
the WhereCondition parameter of OpenReport:

DoCmd.OpenReport "MyReport",,,"[DateField] Between #" & txtStartDate & "#
And #" & txtEndDate & "#"

The DoCmd statement should be all on one line.

Carl Rapson

sive said:
Hi. I'm new to access. I have a table with 8 fields. one of which is a
date.
The table will always be added to each day (the date will change with each
entry). I need to produce a report which allows the user to select a range
of
dates. eg: a report from 1/4/07 to 7/4/07. How does the user select the
date
range?
Thank you. Help is appreciated.
 

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

Top