msgbox if there is no record to report

doran_doran

Registered User.
Local time
Today, 02:33
Joined
Aug 15, 2002
Messages
349
I have a report by date range. That mean end user have to put begining and ending date on a form to view the report.

Is there a way to show a msgbox if there is no record populated by the report. That means if the report does not have any record to display then I want report to display a message box stating there is no record for that time period.

Is it duable. If yes, detail help will be appreciated.

Thanks
Dianna Jamil
 
Found My Answer

> Set the OnNoData property to [Event Procedure] or to the name of a macro that cancels previewing or printing the report.

I just had to put the following code in my OnNoData Property.

MsgBox "There are no records to display / print for that time period"


It works fine.

Thanks everyone.
 
A Different Kinda Error... Can someone Help.....

Please see the Attached picture for error.

Code I am using is below...

Dim strMsg As String, strTitle As String
Dim intStyle As Integer
Beep
strMsg = "There is no data for the period you have selected"
intStyle = vbOKOnly
strTitle = "No Data for Date Range"
MsgBox strMsg, intStyle, strTitle
Cancel = True


Thanks
 

Attachments

  • error.gif
    error.gif
    28.8 KB · Views: 185
Where you have the Docmd.OpenReport you will need to Trap for the Error (On Error Goto ErrorHandler)
 
Specific...

Hi Travis,

Where do I need to include Error Trap?

Do you have any similar code for sample purpose?

Thanks
Dianna Jamil
 
Code:
Public Sub OpenReport()
On Error GoTo ErrorHandler
    DoCmd.OpenReport rptcustomers, acViewPreview
    Exit Sub
ErrorHandler:
    'Err.Number 2497 is the Report Cancel Error Message
    'This will ignore this error
    If Err.Number <> 2497 Then
        MsgBox Err.Number
    Else
        Err.Clear
        Resume Next
    End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom