Two approaches.
1) Re-open the appointmentschedulerfrm in the Close event of the report, which will happen with NoData as well.
2) This is untested but should also work and my preferred method:
Code:
Private Sub Command6_Click()
On Error GoTo Command6_Click_Err
' Hide this form while report is open
Me.Visible = False
'Preview a Report
DoCmd.OpenReport "appttblstaffdateselectedrpt", acViewPreview, "", "", acDialog'previews report
'
'With the the WindowMode of acDialog, the OpenReport command will keep this form open (hidden if you like) and halt the code
'execution in this form right here. When the report completes ir is made invisible, code execution begins agaun right here.
'
Me.Visible = True
'Print a Report
‘ DoCmd.OpenReport "appttblstaffdateselectedrpt", acViewNormal, "", "", acDialog 'prints report
Command6_Click_Exit:
Exit Sub
Command6_Click_Err:
MsgBox "An error has occurred. Please start over. ", vbOKOnly, ""
'DoCmd.Close 'closes current form
'DoCmd.OpenForm "appointmentschedulerfrm", acNormal, "", "", , acNormal 'opens form
Resume Next
End Sub
Please ask questions if you have some.