C
Chuck
A97
I have a form with a command button to open a label report
The label report is based on a query. If the result of the query has no data
because the criteria was not met, how can I prevent the label report from
opening?
The label report module has the following statements:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
On Error GoTo Err_Detail_Print
(Snip special formatting)
Err_Detail_Print:
MsgBox "No Labels Selected To Print", vbOKOnly, "Label Selection Problem"
DoCmd.Close acDefault, acSaveNo
Exit Sub
End Sub
The message box opens, I click OK, The message box closes and the report
opens. The three fields (name, address, city-state-zip) all show #ERROR.
This doesn't hurt anything, it just looks bad. I would like the report to not
open at all and the focus go back the form with the command button to open the
report.
I have tried: DoCmd.Close acReport, "Avery 8160 Labels", acSaveNo
This produced an error message: This action can not be carried out while
processing a form or report event
Chuck
I have a form with a command button to open a label report
The label report is based on a query. If the result of the query has no data
because the criteria was not met, how can I prevent the label report from
opening?
The label report module has the following statements:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
On Error GoTo Err_Detail_Print
(Snip special formatting)
Err_Detail_Print:
MsgBox "No Labels Selected To Print", vbOKOnly, "Label Selection Problem"
DoCmd.Close acDefault, acSaveNo
Exit Sub
End Sub
The message box opens, I click OK, The message box closes and the report
opens. The three fields (name, address, city-state-zip) all show #ERROR.
This doesn't hurt anything, it just looks bad. I would like the report to not
open at all and the focus go back the form with the command button to open the
report.
I have tried: DoCmd.Close acReport, "Avery 8160 Labels", acSaveNo
This produced an error message: This action can not be carried out while
processing a form or report event
Chuck