Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select and print reports from form (2003)

    Is there a way to list all the reports in a db on a form and have a checkbox the user can check to select which reports to print? This db has a data entry form, and the user wants to select specific reports to print after entering the data on the data entry form. I know how to make a command button she can click to print a report. But, she wants a list to pick more than one report. I don't know how to use code, so if you suggest that, please tell me how to use it. Thank you!

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

    Re: Select and print reports from form (2003)

    The attached sample database shows how you can list all reports in a database. It doesn't use check boxes, but a multi-select list box. You can select items in the list box the same way you can select files in Windows Explorer:
    - Click to select an item.
    - Click and drag to select multiple items.
    - Click on one item then Shift+click on another item to select a contiguous range.
    - Click on one item then Ctrl+click on another item to select discontiguous items.
    - Ctrl+click on a selected item to deselect it.
    The list box uses a query qryReports.

    The code behind the "Open" button is

    Private Sub cmdOK_Click()
    Dim itm As Variant
    If Me.lbxReports.ItemsSelected.Count = 0 Then
    MsgBox "Please select at least one report in the list.", vbExclamation
    Me.lbxReports.SetFocus
    Exit Sub
    End If
    For Each itm In Me.lbxReports.ItemsSelected
    DoCmd.OpenReport Me.lbxReports.ItemData(itm), acViewPreview
    Next itm
    End Sub

    If you want to use this in your database, import the query qryReports and the form frmReportSelector from the sample database into your database. It should work without additional coding.
    Attached Files Attached Files

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Select and print reports from form (2003)

    That works cool to open the reports, but how can I automate it so the reports print to the default printer instead of just opening? Typically, the user will only be printing one record at a time, so she wants to enter the data on the data entry form, select the 4-9 reports to print and have them automatically print without her having to click file, print for each one.

    Thanks Hans.

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

    Re: Select and print reports from form (2003)

    I you change acViewPreview to acViewNormal, the reports will be sent directly to the printer.

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Select and print reports from form (2003)

    Just change

    DoCmd.OpenReport Me.lbxReports.ItemData(itm), acViewPreview

    to

    DoCmd.OpenReport Me.lbxReports.ItemData(itm), acViewNormal
    Regards
    John



  6. #6
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Select and print reports from form (2003)

    Perfect. Thank you both!!

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Select and print reports from form (2003)

    This solution is very simple, but in practice I don't usually find it adequate for a two reasons.
    <UL><LI>There are usually some reports in my db I don't want to appear in the list, as maybe they are subreports, they are old versions of reports I have not deleted, or they need to be opened in a specific context.
    <LI>The Name of the report (beginning with rpt and having no spaces) is not a good selector for the report for users.[/list]So I have a separate table tblReportList which I manually maintain to include the reports I want listed. This table has two fields, one is the actual name of the report, the other is the words I display to users in the list box.

    So rptAttendeeList might display as "Full List of Course Attendees".

    I base my listbox on this table. The first column has the actual report name in it, but has a coumn width of zero so it is not seen.
    Regards
    John



  8. #8
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Select and print reports from form (2003)

    Ohhh.. good points. Thank you! For my purposes right now, Hans' solution works fine. But, I like your solution too. I will try it.

Posting Permissions

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