hi Tony,
Tony said:
I have a report which I run to return data over a specified time span. If
there is no data I have an message box that appears in the OnNodata
Event. However I also get a message that says "Runtime error 2585 This
process can't be carried out while processing a report or form event"
What do I need to do to stop that message appearing?
I''m using these functions:
--
Public Function ReportNoData(AReport As Access.Report)
On Local Error Resume Next
Dim ReportCaptionName As String
ReportCaptionName = AReport.Caption
If ReportCaptionName = "" Then ReportCaptionName = AReport.Name
FormMsgBox "No data available for report " & _
SQLQuote(ReportCaptionName) & "."
DoCmd.CancelEvent
End Function
Public Function ReportOpen(AReportName As String, _
Optional AView As AcView = acPreview, _
Optional AFilterName As String = "", _
Optional AWhereCondition As String = "", _
Optional AWindowMode As _
Access.AcWindowMode = acWindowNormal _
) As Boolean
On Local Error Resume Next
If CurrentProject.AllReports.Item(AReportName).IsLoaded Then
DoCmd.Close acReport, AReportName
End If
On Local Error GoTo LocalError
DoCmd.OpenReport AReportName, AView, AFilterName, _
AWhereCondition, AWindowMode
On Local Error Resume Next
Reports(AReportName).ZoomControl = 0
ReportOpen = True
Exit Function
LocalError:
If Err.Number <> 2501 Then ' ReportNoData Fehler
FormErrMsgBox "Error while opening report."
End If
ReportOpen = False
End Function
--
Just assign =ReportNoData([Report]) to your no data event and use
ReportOpen "yourReportName" to show or print it.
mfG
--> stefan <--