Creating a Report but no Data

If I run the form I get no data ...
Popup (There are no records for that selection)
Popup (The Open Report action was cancelled)

Hello,

i'm setting up NoData handling in some of my reports. my issue is that i don't know how to prevent the second default popup ("The OpenReport action was cancelled"). I don't want my users to have to click twice for the same report - they have already been told there is no data via a personalised popup (the first one)... i tried the set warnings false before the cancel action, then true after again but it gives me an error "argument not optional" and it highlights my setwarnings true argument in debug.

perhaps i got the syntax/order of actions incorrect?

Code:
Private Sub Report_NoData(Cancel As Integer)
            
    MsgBox "There is no exercise data for this horse." _
        & Chr(13) & "Please add some data before creating a report." _
        , vbInformation, "The PED - No data"
           
   DoCmd.SetWarnings = False
    Cancel = True
   DoCmd.SetWarnings = True
    
End Sub
Cheers,
wiklendt
 
got it, thanks: the solution was to put this code in the error handing for the onclick event that invokes the report:

Code:
    Select Case Err.Number
      Case 2501
         'ignore, not an Error
      Case Else
        Msg = "Error # " & Str(Err.Number) & Chr(13) & Err.Description
        MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
    End Select
 
got it, thanks: the solution was to put this code in the error handing for the onclick event that invokes the report:

Code:
    Select Case Err.Number
      Case 2501
         'ignore, not an Error
      Case Else
        Msg = "Error # " & Str(Err.Number) & Chr(13) & Err.Description
        MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
    End Select

You could even shorten it a bit more by using:

Code:
    If Err.Number <> 2501
        Msg = "Error # " & Str(Err.Number) & Chr(13) & Err.Description
        MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
    End Select
 

Users who are viewing this thread

Back
Top Bottom