no data, close report (1 Viewer)

deekras

Registered User.
Local time
Today, 10:35
Joined
Jun 14, 2000
Messages
169
i know i should be able to find the answer to this on my own, but i can't.

I have a dailog to get dates and company name for reports. i have this coding set to trap for errors. if there are no errors, open report.

If IsNull([begindate]) Then
MsgBox "You must enter a beginning date.", 0, "Missing Data"
DoCmd.GoToControl "Begindate"
Else
If [begindate] > [enddate] Then
MsgBox "Ending date must be greater than Beginning date.", 0, "Date Invalid"
DoCmd.GoToControl "Begindate"
Else
DoCmd.OpenReport "transactions by account", acPreview
End If
End If

On NoData in teh report, i have this coding:

Private Sub Report_NoData(Cancel As Integer)
MsgBox ("There is no data for this company for dates selected"), 0, "No Data for Report"
DoCmd.CancelEvent

If there is no data, it displays the messge, but then has a run time error 2501 - The OpenReport action was cancelled.
 
R

Rich

Guest
Solutions Employee Sales dialogue look at the codes behind the form.
HTH
 

Users who are viewing this thread

Top Bottom