Double dates

B

bladelock

Here is my code in the Event Procedure of the command button:

Dim stDocName As String

stDocName = "Other part1"
DoCmd.SetWarnings False

DoCmd.OpenQuery stDocName, acNormal, acEdit

DoCmd.SetWarnings True

stDocName = "Other Modified"
DoCmd.OutputTo acOutputReport, stDocName, acFormatXLS,
"OTHERMODIFIED.xls", True

Basically, this procedure runs the first query and updates the datebase. The
query ask for two dates, starting date and ending date. The second part of
the procedure then runs a report. That report is associated with a query that
also ask for the same two dates, starting date and ending date.
The question: How can I fix the procedure where the user only has to enter
one set of date, starting date and ending date. In other words, I only want
the user entering the dates ing the first query and then pass those dates the
the next query associated to the report piece. Thanks.
 
C

Chris Reveille

Create a foe with 2 unbound text boxes. From Date and To Date
Get use the dates on the form in the queries and reports. Add a command
button to the form to run the macro.
 
J

John W. Vinson

Basically, this procedure runs the first query and updates the datebase. The
query ask for two dates, starting date and ending date. The second part of
the procedure then runs a report.

Create a little unbound Form, frmCrit, with two textboxes txtFrom and txtTo.
In your two queries (the update query and the report's recordsource) use
= Forms![frmCrit]![txtFrom] AND < DateAdd("d", 1, Forms![frmCrit]![txtTo])

as a criterion. The DateAdd bit makes sure that dates with a time portion get
included if they are on the last day of the range.

John W. Vinson [MVP]
 

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