Cnacel on No Data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The code below is called when by the On NO Data Event of a report. I need to
stop the report from running if the user selects NO, but leave the option
open to run a blank report. I am using a Public Function because I need to
call this from a large number of reports.

I am really looking for the line that will stop the report if the user
selects "Case vbNo". The "yes" is no problem since the report runs regardless
of the selection.


Public Function NoData()
Select Case MsgBox("Message", vbYesNo vbDefaultButton1, "MessageTitle")

Case vbYes

Case vbNo

End Select
End Function
 
It is not <g>

Private Sub Report_NoData(Cancel As Integer)
Select Case MsgBox("Message", vbYesNo vbDefaultButton1, "MessageTitle")
Case VBA.vbNo
Cancel = True
Case Else
' ...
End Select
End Sub
 
Thanks. I had tried this before posting. I get a "Report Action was
cancelled" message. With or without error handling.
 
You have to add error handling to the calling code
ie

On Error Resume Next
Access.Docmd.OpenReport "myRep"

HTH

Pieter
 
Back
Top