Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Rockville, MD USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening Multiple Reports (2002)

    I am trying to open two reports on the click of one command button. Each report has the code to cancel itself if there is nodata. The code behind the command button simply runs the docmd.openreport code for each report and a query provides the records. I find that if the first report to open has nodata then the second report does not open even if it does have data.

    Does the cancel event shut down the whole process running behind the command button i.e. canceling the code running or does it shut down the report that contains the cancel event code?

    Is there a way to better evaluate the results of the query prior to the report being generated?

    TIA

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

    Re: Opening Multiple Reports (2002)

    If the opening of a report is canceled because there are no data to display, error 2501 occurs: action canceled by user. You can trap this error. Try something like the following (substitute the appropriate names):

    Private Sub cmdReports_Click()
    On Error GoTo ErrHandler

    DoCmd.OpenReport "rptFirstReport", acViewPreview
    DoCmd.OpenReport "rptSecondReport", acViewPreview
    Exit Sub

    ErrHandler:
    If Err = 2501 Then ' OpenReport was canceled
    Resume Next
    Else
    MsgBox Err.Description, vbExclamation
    End If
    End Sub

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    Rockville, MD USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening Multiple Reports (2002)

    Thank you Hans....

    As usual excellent direction! <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

Posting Permissions

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