Re: How to get report not to run on No Data
- From: "M.L. Sco Scofield" <Sco@xxxxxxxxxx>
- Date: Mon, 11 Jul 2005 10:19:27 -0600
You need to include Cancel = True in the report's Report_NoData event. I.e.:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is not data to display for this report", vbInformation, "No
Data"
Cancel = True
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you are opening the report with DoCmd.OpenReport, you'll need to add a
little error handling to prevent the infamous 2501 user canceled message.
I.e.:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub cmdOpenReport_Click()
On Error GoTo ErrorRoutine
DoCmd.OpenReport "rptYourReportName", acViewPreview
ExitProcedure:
Exit Sub
ErrorRoutine:
If Err.Number = 2501 Then
'Canceled - Do nothing
Else
MsgBox Err.Description, vbCritical, "Bad Error"
End If
Resume ExitProcedure
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Good luck.
Sco
M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Denver Area Access Users Group Vice President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
<doyle60@xxxxxxx> wrote in message
news:1121097751.209627.44400@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I can't seem to interrupt a report from running when there is no data.
> The report has a image control that is set on the On Print property of
> the section it is in:
>
> Photo.Picture = PhotoPathStyle
>
> This gets an error only when there is no data.
>
> I put a message in the OnNoData property of the form that the user
> should pick something. But this doesn't stop the error from coming up.
> The error is Run-time error '13': Type mismatch, which doesn't seem to
> mean much.
>
> I can't get the print button not to deactivate if a user picks nothing,
> the subject of another post here. So I thought to let the user press
> the print, give him a warning, and be done with it. But no.
>
> Thanks,
>
> Matt
>
.
- Follow-Ups:
- Re: How to get report not to run on No Data
- From: doyle60@xxxxxxx
- Re: How to get report not to run on No Data
- References:
- How to get report not to run on No Data
- From: doyle60@xxxxxxx
- How to get report not to run on No Data
- Prev by Date: Re: Creating Event Procedure Programatically
- Next by Date: Changing field based on size
- Previous by thread: How to get report not to run on No Data
- Next by thread: Re: How to get report not to run on No Data
- Index(es):