Results 1 to 2 of 2

Thread: OutputTo (2002)

  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Indianapolis, Indiana, USA
    Thanked 0 Times in 0 Posts

    OutputTo (2002)

    Hello All,
    I have:

    Function OTRun()

    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"

    End Function

    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?


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 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
    End Sub
    - 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts