Hi, I have some vba code which opens a series of reports as follows:
On Error GoTo Err_Command7_Click
Dim SinglesCatchup As Variant
Dim MultiplesCatchUp As Variant
Dim MagazineName As Variant
MagazineName = Me.Mag.Column(1)
MagazineName = MagazineName
SinglesCatchup = MagazineName & "_CATCHUPSINGLES"
MultiplesCatchUp = MagazineName & "_CATCHUPMULTIPLES"
DoCmd.OpenReport SinglesCatchup, acViewPreview
DoCmd.OpenReport MultiplesCatchUp, acViewPreview
DoCmd.OpenReport "CatchUpSummary", acViewPreview
Exit_Command7_Click:
Exit Sub
Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click
My problems is when the reports have no data they cause an error to occur which asks the user to end or debug and then presents the report in design view. I have some cod ein the on no data event but this is still happening and thus forcing itself out of the code and not continuing with the rest of it which is absolutely vital.
This is the code behind the report I am opening and is erroring on the first line of the first part:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Text149 = 2 Then
Me.Box54.Visible = True
Else
Me.Box54.Visible = False
End If
If Me.Text149 = 2 Then
Me.Image156.Visible = True
Me.Image157.Visible = False
Else
Me.Image156.Visible = False
Me.Image157.Visible = True
End If
End Sub
Private Sub Report_NoData(Cancel As Integer)
Dim emptyRecord As Variant
emptyRecord = MsgBox("No records for MET Multiple CatchUp", vbExclamation, "Warning: No Data"
Cancel = True
End Sub
How can I open all reports which have data and gracefully realise there is no data when this is true but still continue executing the subsequent code. I would be most greatful if anyone could help.
Thanks
Steph
On Error GoTo Err_Command7_Click
Dim SinglesCatchup As Variant
Dim MultiplesCatchUp As Variant
Dim MagazineName As Variant
MagazineName = Me.Mag.Column(1)
MagazineName = MagazineName
SinglesCatchup = MagazineName & "_CATCHUPSINGLES"
MultiplesCatchUp = MagazineName & "_CATCHUPMULTIPLES"
DoCmd.OpenReport SinglesCatchup, acViewPreview
DoCmd.OpenReport MultiplesCatchUp, acViewPreview
DoCmd.OpenReport "CatchUpSummary", acViewPreview
Exit_Command7_Click:
Exit Sub
Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click
My problems is when the reports have no data they cause an error to occur which asks the user to end or debug and then presents the report in design view. I have some cod ein the on no data event but this is still happening and thus forcing itself out of the code and not continuing with the rest of it which is absolutely vital.
This is the code behind the report I am opening and is erroring on the first line of the first part:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Text149 = 2 Then
Me.Box54.Visible = True
Else
Me.Box54.Visible = False
End If
If Me.Text149 = 2 Then
Me.Image156.Visible = True
Me.Image157.Visible = False
Else
Me.Image156.Visible = False
Me.Image157.Visible = True
End If
End Sub
Private Sub Report_NoData(Cancel As Integer)
Dim emptyRecord As Variant
emptyRecord = MsgBox("No records for MET Multiple CatchUp", vbExclamation, "Warning: No Data"
Cancel = True
End Sub
How can I open all reports which have data and gracefully realise there is no data when this is true but still continue executing the subsequent code. I would be most greatful if anyone could help.
Thanks
Steph