Results 1 to 2 of 2
Thread: OutputTo (2002)
2006-08-15, 02:36 #1
- Join Date
- Jun 2001
- Indianapolis, Indiana, USA
- Thanked 0 Times in 0 Posts
Dim DateRange As String, Date1 As Date, Date2 As Date
Date1 = (#1/1/2006#)
Date2 = Date1 + 6
DateRange = " >= " & Date1 & " <= " & Date2
DoCmd.OutputTo acOutputQuery, "qryOTHrs", acFormatXLS, "C:tempTest.xls"
What I want to do is run the qryOTHrs but filter it based on "DateRange". Then I am going to loop through the weeks until the current week, at which time I will stop the code. You can see that I want to output this query as a XL sheet. How can I put in a filter on the outputto method?
2006-08-15, 04:44 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Re: OutputTo (2002)
Your DateRange string doesn't make sense, but you can't do it this way anyway. Try the following:
- Create a form frmOutput.
- Place a text box txtDate on the form.
- Set its Format property to Short Date or another date format.
- Put a command button cmdOutput on the form.
- Create an On Click event procedure for the command button.
Private Sub cmdOutput_Click()
Dim dtmDate As Date
dtmDate = DateSerial(Year(Date), 1, 1)
Do While dtmDate < Date
Me!txtDate = dtmDate
DoCmd.OutputTo acOutputQuery, "qryOTHrs", acFormatXLS, _
"C:tempTest" & Format(dtmDate, "yymmdd") & ".xls"
dtmDate = dtmDate + 7
- Open qryOTHrs (or a copy of the query if you'd rather not modify the original) in design view.
- Put the following in the Criteria line for the date field on which you want to filter:
Between [Forms]![frmOutput]![txtDate] And [Forms]![frmOutput]![txtDate]+6
- Close and save the query.