on a switchboard form, I have a button that when pressed, will print each report out, one at a time, in order.
The third to last report is dependant on data being present.
I have an event when the report is opened with no data:
(the queries need to be run in order to compile the data)
The printing dialog (with the cancel button) comes up:
Then an error comes up, that I trap using "MsgBox" code above:
Then my message saying:
then a VB message:
Does anyone have any suggestions as to how I can get it to MsgBox the warning about no data BEFORE anything prints, and then halting everything?
Or any other suggestions that may help!
Thanks in advance,
Aubs
The third to last report is dependant on data being present.
I have an event when the report is opened with no data:
Code:
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ErrorNoData
MsgBox "There is no data available to generate this report", vbOKOnly, ""
Cancel = True
ExitNoData:
Exit Sub
ErrorNoData:
MsgBox Err.Description
Resume ExitNoData
End Sub
[code]
The problem is, I use the following to print the report:
[code]
DoCmd.SetWarnings False
DoCmd.OpenQuery "quyElementsNonCompliantCreateTable"
DoCmd.OpenQuery "quyElementsNonCompliantDeleteRedundentZZs"
DoCmd.SetWarnings True
stDocName = "rptElements-NonCompliant"
MsgBox "Err: " & Err & vbcr & "Desc: " & Err.Description
DoCmd.OpenReport stDocName, acNormal
The printing dialog (with the cancel button) comes up:
Code:
"Now Printing..."
Then an error comes up, that I trap using "MsgBox" code above:
Code:
Err: 13
Desc: Type mismatch
Then my message saying:
Code:
"There is no data available to generate this report"
then a VB message:
Code:
Run-time error '2501':
The OpenReport action was canceled.
[End] [Debug]
Does anyone have any suggestions as to how I can get it to MsgBox the warning about no data BEFORE anything prints, and then halting everything?
Or any other suggestions that may help!
Thanks in advance,
Aubs