Consulting

Results 1 to 4 of 4

Thread: Adding a filter to reports

  1. #1

    Adding a filter to reports

    Here is an interesting one for you guys. On a form, I have two command buttons. Both of them call the same report. One of them displays the report and one of them outputs the report to a pdf file. However, the method of calling the report differs.

    This command opens the report perfectly on the screen. a_Season(x,y) provides a 'start' and an 'end' date range.

    Private Sub cmdClassSchedule_Click()
    DoCmd.OpenReport "rpt_Class_Schedule", acViewReport, , _
    "(left([Class_Type_Code],3) = 'GVR') AND [Date_1] >= #" & a_Season(1, 2) & _
    "# AND [Date_1] <= #" & a_Season(1, 3) & "#"
    End Sub

    This command outputs the report to the appropriate pdf file.

    Private Sub cmdCreatePDF_Click()
    Dim strPath As String
    strPath = CurrentProject.Path
    DoCmd.OutputTo acOutputReport, "rpt_Class_Schedule", "PDF Format", strPath & "\Class_Schedule.pdf"
    End Sub


    My issues is that I need to send the file to a pdf file but the DoCmd.OutputTo command doesn't all for the filter.

    I don't want to have to create two identical reports with different queries.

    any ideas?
    ttfn

    Kicker

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    There are a few methods to do this
    a. Hard code the Filter in the Report. (Easy)
    b. Hard code the filter in the Report's underlying Query. (Easy)
    c. Program the Query from the Form. (Fairly easy)
    d. Create the Query for the Report using the QueryDef. (Harder)
    e. Create an SQL and assign to the report using VBA. (Also Harder).

  3. #3
    OBP. Yeah, I was kinda thinking the same thing.

    There are a few methods to do this
    a. Hard code the Filter in the Report. (Easy). I only want the report to select a specific range of dates within the entire table so I need to send those dates when the report is printed.
    b. Hard code the filter in the Report's underlying Query. (Easy).This won't allow me to control the dates very easily
    c. Program the Query from the Form. (Fairly easy).. I was thinking about this. If I use some public date variables and set them with VBA, that might work. But, I am calling the reports from many directions and that might get confusing. But this looks like the best option
    d. Create the Query for the Report using the QueryDef. (Harder)
    e. Create an SQL and assign to the report using VBA. (Also Harder).

    thank you for your ideas. I will let you know the solution once written


    JoinedMar 2005Posts2,592Location

    There are a few methods to do this
    a. Hard code the Filter in the Report. (Easy)
    b. Hard code the filter in the Report's underlying Query. (Easy)
    c. Program the Query from the Form. (Fairly easy)
    d. Create the Query for the Report using the QueryDef. (Harder)
    e. Create an SQL and assign to the report using VBA. (Also Harder)


    ttfn

    Kicker

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Let me know if you need any help.

Posting Permissions

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