Cancel - on no data

  • Thread starter Thread starter Junior
  • Start date Start date
J

Junior

Opening a report from a form -
When the report is closed i want to return to the form-
If the report has data the report close event will do this -
DoCmd.OpenForm "frmReports", acNormal, "", "", , acNormal

HOWEVER- if there is NO data - i also want the focus to return to the form
using the no data event - How do i return to the form if no data?

Private Sub Report_NoData(Cancel As Integer)
'(error handling ommitted)
MsgBox "There is no data to report." _
, vbOKOnly + vbInformation, "No Data Found"
Cancel = True
End Sub
 
Either add the DoCmd step to the OnNoData code, or call the Close event code
for the report (assuming that the opening of the form is the only code step
in the OnClose procedure):

Private Sub Report_NoData(Cancel As Integer)
'(error handling ommitted)
MsgBox "There is no data to report." _
, vbOKOnly + vbInformation, "No Data Found"
Cancel = True
DoCmd.OpenForm "frmReports", acNormal, "", "", , acNormal
End Sub



Private Sub Report_NoData(Cancel As Integer)
'(error handling ommitted)
MsgBox "There is no data to report." _
, vbOKOnly + vbInformation, "No Data Found"
Cancel = True
Call Form_Close
End Sub
 
Back
Top