Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBA with reports and queries 1

Status
Not open for further replies.

medium

MIS
Aug 28, 2002
30
US
I have a report (ie. report1) that is based on a query (ie. query1). There is a date field that I have in the query. I also have a form that is used to input two dates for a range of dates. Using VBA, I know that it is possible to sort a record by a particular field in the report. However, is it possible to open the query and feed in my two dates from the form then have the query only display those dates? Then open the report that is based on the query.

Perhaps I am going about this the wrong way. However, ultimately, I need to filter the dates in report1 so that only dates within the range entered into the form are displayed. The only way I can think to do this is through query1 and since report1 is based on the query, report1 will only display the dates within the range.

If someone can give some kind of lead about how to feed the two dates into the query, I know how to do the rest. But if one would like to wax eloquent about the whole problem, that would be fine too.

Thanks in advance for the help. :)



 
medium,

Here's the criteria I would use in the date field of the Query:

>=[forms]![frm_your_form]![Textbox_date1] And <=[forms]![frm_your_form]![Textbox_date2]

This will select only the records with a date between date1 and date2.

Set your report's record source as the Query and you should be good-to-go.

Let me know if this helps. -illini
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top