Culling through data in a report

E

Edward Owen

I have a database with a lot of records, each with a start date for them. I
want to be able to pull up all records based on a start date along with
those for the next week or 30 days, not printing those far off in the
distance. What's the easiest way to insert this in my query to pull up
these parameters?

Thanks!
 
T

tina

suggest you create an unbound form, and add two textbox controls to it. name
the form frmDateRange, and name the controls txtStartDate and txtNumOfDays.
add a command button that uses a macro or VBA code to open the query - or
better yet, to open a form bound to the query, or open/print a report bound
to the query.

in the query, set the following criteria on the start date field, as

Between [Forms]![frmDateRange]![txtStartDate] And
[Forms]![frmDateRange]![txtStartDate]+[Forms]![frmDateRange]![txtNumOfDays]

the above goes all on one line in the criteria grid. on the menu bar, click
Query | Parameters and enter

[Forms]![frmDateRange]![txtStartDate]

in the Parameter column, and Date/Time in the Data Type column.

note that if your dates also have specific times attached to them in the
date field, then you'll have to add 1 day to the range you want; for
instance if you want 11/15/2005 + 7 days, you'll need to enter an 8 in the
txtNumOfDays control on the form. otherwise you'll get data from 11/15/2005
through 11/21/2005 - *not* 11/22/2005.

hth
 
J

John Vinson

I have a database with a lot of records, each with a start date for them. I
want to be able to pull up all records based on a start date along with
those for the next week or 30 days, not printing those far off in the
distance. What's the easiest way to insert this in my query to pull up
these parameters?

Thanks!

A criterion of
= CDate([Enter start date:]) AND <= DateAdd("d", 30, CDate([Enter start date:]))

should do the trick for you...

John W. Vinson[MVP]
 
E

Edward Owen

Worked like a charm!

Thanks!


John Vinson said:
I have a database with a lot of records, each with a start date for them.
I
want to be able to pull up all records based on a start date along with
those for the next week or 30 days, not printing those far off in the
distance. What's the easiest way to insert this in my query to pull up
these parameters?

Thanks!

A criterion of
= CDate([Enter start date:]) AND <= DateAdd("d", 30, CDate([Enter start
date:]))

should do the trick for you...

John W. Vinson[MVP]
 
Top