Results 1 to 5 of 5
  1. #1
    TimMoffy is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    29

    Print all reports from a select statement

    Can somebody advise me please on the most efficient way to print all reports from a select statement.

    Currently my code looks like this: NB: Ignore the Case 999 part - that is where I would like to put the answer to the question that follows.

    Private Sub cboQList_AfterUpdate()
    Dim strReportName As String
    Select Case cboQList.Value


    Case "1"
    strReportName = "rptFQ11Comments"
    Case "2"
    strReportName = "rptFQ12Comments"
    Case "3"
    strReportName = "rptFQ13Comments"
    Case "4"
    strReportName = "rptFQ21Comments"
    Case "999"
    "Print all of the above reports"
    End Select
    DoCmd.OpenReport strReportName, acViewPreview

    and it works well.
    Whenever a selection is made from the combo box, cboQlist, the report opens up in preview mode just as I want it to.

    However what I would also like is to offer from the same combo box is the option to print all of the reports by choosing the option where case is 999. In reality there are some 20+ reports, so opening them all in preview mode doesn’t seem a very good way to present the reports to the user, by opening 20+ preview windows, but directly printing them all would work well.

    I could make another report with existing reports all as sub reports I guess, but feel there must be a more elegant way of achieving what I want, without having to resort to such a report.

    The other option I guess is to create a command button alongside the combo box to click to print all reports, but again it doesn’t seem very elegant.
    Any great ideas would be very gratefully received.
    Thanks in advance.

  2. #2
    TimMoffy is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    29
    apologies for not putting the code in the correct format - missed that one until after i had posted.

  3. #3
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    I've done this using 2 command buttons 1 to preview the report and 1 to print directly to the printer. allowing the user to select which they want to do. Copy the code from the preview command button to the print command button and change the following:

    Code:
    'From:
    DoCmd.OpenReport strReportName, acViewPreview
    'To:
    DoCmd.OpenReport strReportName, acViewNormal
    That will print each report direct. To print all of the Reports you would have to do a for next loop within the Case 999 Section as well as build an Array with the report names. I also believe there is a way using for each and the Reports collection but that would print every single report in your DB.

    Code:
    Case "999"
           For lngcnt = 1 to 20
                DoCmd.OpenReport reportname(lngcnt), acViewNormal
           next lngcnt

  4. #4
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    After posting I re-read my post and it's clear as mud. The first code section prints a single report the same as viewing that report. The second prints each report defined in the reportname Array. Hope that's clearer

  5. #5
    TimMoffy is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    29
    Thank you - seems to work a treat.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Multi Select Combo box for print function
    By jparker1954 in forum Reports
    Replies: 11
    Last Post: 09-17-2011, 03:08 PM
  2. Replies: 3
    Last Post: 05-05-2011, 09:33 AM
  3. Print different Reports at once
    By Brian62 in forum Reports
    Replies: 5
    Last Post: 01-21-2011, 11:19 AM
  4. Combo box to select report to Print
    By usmcgrunt in forum Reports
    Replies: 4
    Last Post: 09-17-2010, 06:44 PM
  5. Option to Print Sub-reports
    By Hotwheels59 in forum Reports
    Replies: 0
    Last Post: 06-21-2010, 03:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums