Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Report Filter Not Working For Me? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I have the following code on a print button on a form

    If strObjectType = "R" I get my filtered preview report and the filtered report written to the text file

    If strObjectType = "P" I get my filtered printed report, however I get the entire unfiltered file written to the text file

    Why am I getting the entire unfiltered file written to the text file?

    Any thoughts?

    Thanks, John

    <pre>strFilter = "[lngRevTranID]=" & Me!lngRevTranID

    If strObjectType = "R" Then ' open report
    DoCmd.OpenReport strDocName, acPreview, , strFilter
    Else
    DoCmd.OpenReport strDocName, , , strFilter
    End If

    strCurrentBackendDBPath = GetCurrentBackendDBPath

    strOutput = strCurrentBackendDBPath & "R" & Me.lngRevTranID & ".txt"
    bRetVal = DeleteAnyDiskFile(strOutput)

    DoCmd.OutputTo acOutputReport, strDocName, acFormatTXT, _
    strOutput, False
    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Report Filter Not Working For Me? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Because OutputTo doesn't accept filters or parameters. I would suggest you use something like TransferText and export a query using the same filter string.
    Charlotte

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report Filter Not Working For Me? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Thanks for the heads up. For some reason this technique working for me until example I posted previously.

    I recoded as follows and this seems to work, do you see any problems with this?

    Thanks, John


    <pre>Dim strSQL As String
    Dim strTable As String
    Dim strID As String
    Dim strOrderBy As String

    strTable = "qrytbl_RevTran_MasterDetail"
    strID = "lngRevTranID"
    strOrderBy = "RevCode, lngSeqNo"

    strSQL = "SELECT * " _
    & "FROM " & strTable & " " _
    & "WHERE (((" & strTable & "." & strID & ")=" _
    & Me!lngRevTranID & ")) " _
    & "ORDER BY " & strOrderBy

    gloSetValue "ReportRecordSource", strSQL

    If strObjectType = "R" Then ' open report
    DoCmd.OpenReport strDocName, acPreview
    Else
    DoCmd.OpenReport strDocName
    End If

    strCurrentBackendDBPath = GetCurrentBackendDBPath
    strOutput = strCurrentBackendDBPath & _
    "R" & _
    cfpadvalue(Me.lngRevTranID, "0", True, 7) & _
    ".txt"

    bRetVal = DeleteAnyDiskFile(strOutput)

    DoCmd.OutputTo acOutputReport, strDocName, acFormatTXT, _
    strOutput, False


    Private Sub Report_Open(Cancel As Integer)

    Me.RecordSource = gloGetValue("ReportRecordSource")

    End Sub
    </pre>


  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Report Filter Not Working For Me? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I'm not Charlotte, but in so far as I can follow the code, it looks OK to me. Setting the record source in the On Open event of the report should work with OutputTo.

Posting Permissions

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