Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Florida, USA
    Posts
    394
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print all reports (Office 2000)

    Hi,
    Is there a way that I can create a command button that will print all of the reports in the reports section of Access one after the other? Even better, if they can be printed in a specific order? I am currently printing them one at a time.

    Thanks!
    Louise

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

    Re: Print all reports (Office 2000)

    How would you like to specify the order in which they are printed?

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Florida, USA
    Posts
    394
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print all reports (Office 2000)

    Hi Hans,
    Not sure about your question. The current reports are these: Publicity Report, Sponsor Tickets Report, Ticket Revenue Report, Ticket Report, Captain's List, Captain & Anglers, Boats & Observers, Boat Make & Length, Observer List. I'm sure I'll be adding more as time goes on and the order will probably change as well. But if I know how, I'll be able to play with it again, hopefully.
    Louise

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

    Re: Print all reports (Office 2000)

    Well, you asked
    <hr>Even better, if they can be printed in a specific order?<hr>
    You will have to tell us how you want to specify this order - I don't know it and Access cannot guess it.

  5. #5
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Florida, USA
    Posts
    394
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print all reports (Office 2000)

    Hi Hans,

    "You will have to tell us how you want to specify this order - I don't know it and Access cannot guess it."

    I'm sorry if I was dumb. My earlier reply listed my reports in order. Is that what you meant?

    Thanks,
    Louise

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

    Re: Print all reports (Office 2000)

    Well, you can, of course create code like this:

    DoCmd.OpenReport "Publicity Report"
    DoCmd.OpenReport "Sponsor Tickets Report"
    DoCmd.OpenReport "Ticket Revenue Report"
    DoCmd.OpenReport "Ticket Report"
    DoCmd.OpenReport "Captain's List"
    DoCmd.OpenReport "Captain & Anglers"
    DoCmd.OpenReport "Boats & Observers"
    DoCmd.OpenReport "Boat Make & Length"
    DoCmd.OpenReport "Observer List"

    But that's not very flexible - each time you add or remove a report or want to change the order, you'd have to modify the code.
    Another way would be to create a table with two fields: ReportName (text) and PrintOrder (number).

    <table border=1><td align=center>ReportName</td><td align=center>PrintOrder</td><td>Sponsor Tickets Report</td><td align=right>2</td><td>Publicity Report</td><td align=right>1</td><td>...</td><td align=right>...</td></table>
    You can create a query based on the table that sorts the records by PrintOrder.
    In your code, you'd open a DAO or ADODB recordset on this query, loop through the records, and print the report whose name is in the ReportName field.
    You'd have to edit this table when you want to add or remove reports or change the order. But that's easier than editing code, and it doesn't require that you open the databse exclusively.

  7. #7
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Florida, USA
    Posts
    394
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print all reports (Office 2000)

    Hi Hans,
    The table looks promising but I don't know what: "In your code, you'd open a DAO or ADODB recordset on this query, loop through the records, and print the report whose name is in the ReportName field." means. So I guess I'll just stick to printing them one at a time for now.

    Thanks anyway.
    Louise

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

    Re: Print all reports (Office 2000)

    Say the query is named qryReports, with fields as indicated. Code could look like this in the On Click event procedure of a command button on a form:

    Private Sub cmdReports_Click()
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset

    On Error GoTo ErrHandler

    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("qryReports", dbOpenForwardOnly)
    Do While Not rst.EOF
    DoCmd.OpenReport rst!ReportName
    rst.MoveNext
    Loop

    ExitHandler:
    On Error Resume Next
    rst.Close
    Set rst = Nothing
    Set dbs = Nothing
    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

    You must set a reference to the Microsoft DAO 3.6 Object Library in Tools | References in the Visual Basic Editor for this code to work.

Posting Permissions

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