I have a report that prints fine when there is data. However, when there is no data, I get an error msg and the report doesn't run. I think this is because of some code that I put in the Format event of the detail section to remove labels on fields where there was no data. For example:
If IsNull(txtOutcome) Or txtOutcome = "" Then
Me.lbloutcome.Visible = False
Else
Me.lbloutcome.Visible = True
End if
I put this in the No Data event for the report:
On Error Resume Next
MsgBox "Sorry, there is no data in this report"
But I still get an error. I think it's because the No Data event occurs *after* the report has already been formatted for printing. Is there any way around this? And when I commented out the entire formatting section, I *did* get my msg box, but it appeared twice. Why would that happen? And I tried preventing the report from even opening without data, but then I get an error from the form that opens the report.
Any ideas? I'm freaking out because I thought I was *done* with this thing and could move on, but now I can't.
TIA
If IsNull(txtOutcome) Or txtOutcome = "" Then
Me.lbloutcome.Visible = False
Else
Me.lbloutcome.Visible = True
End if
I put this in the No Data event for the report:
On Error Resume Next
MsgBox "Sorry, there is no data in this report"
But I still get an error. I think it's because the No Data event occurs *after* the report has already been formatted for printing. Is there any way around this? And when I commented out the entire formatting section, I *did* get my msg box, but it appeared twice. Why would that happen? And I tried preventing the report from even opening without data, but then I get an error from the form that opens the report.
Any ideas? I'm freaking out because I thought I was *done* with this thing and could move on, but now I can't.
TIA