realnine
07-01-2003, 07:55 PM
I did a search with my question and found no solutions that work. I have a report that lists and counts the jobs and amtBilled in the currenet month. The first day of the month there are no jobs listed in the querry. The report writer (print preview view) in the details footer gives err on all the Sum and count calculations. The details section is blank. This freaks the user out because they think something serious it worng.
I am able to display a message box in the report properties-event-on nodata
=MsgBox("No Data Entered",0,"No Data Entered")
After the user clicks OK the form appears with the err in all the footer fields. How can I close the form after the No Data Entered mesage with out it loading in the print preview.
Thanks
WayneRyan
07-01-2003, 08:36 PM
Real,
In the NoData event:
MsgBox("There is no matching data")
DoCmd.Close
Wayne
realnine
07-02-2003, 07:16 AM
Wayne,
Thanks for your response,
I tried that code before posting for help. It has the following results
Runtime error 2585
This action can not be carried out while processing a from or report event.
Is there some other way of aborting a report?
Post the code behind your report
realnine
07-02-2003, 09:32 AM
Originally posted by Rich
Post the code behind your report
Rich,
I don't understand "behind your report" I am using the report properties-event-on no data.
I thinkI need some code something like this
If querry field is null Then
MsgBox "No Data"
DoCmd.Close
End If
I am not that proficient in writhing VB code.
jeremie_ingram
07-03-2003, 07:22 AM
If querry field is null Then
Is this a parameter query you are baseing the report off of? Do they need to make a selection or enter something on a form, then click a cmd button to open the report, or do they just select a report from a menu?
How the report is opened can play a big role in stopping it as well. If you go to the properties of the report you should be able to do as WayneRyan said, but try adding the line DoCmd.SetWarnings = False at the begining and True at the end and see if that ends the message.
realnine
07-03-2003, 08:03 AM
Thanks Everyone for your help.
I stumbled into a solution. Here is the code I put into the
Form-Properties-Event-On No Data
Private Sub Report_NoData(Cancel As Integer)
MsgBox ("No Tows Entered for this month")
DoCmd.CancelEvent
End Sub
I replaced the DoCmd.Close as suggested by Wayne with DoCmd.CancelEvent and it works just the way I want. The report is called from a command button on the main form. If there is no data in the supporting querry the message is displayed and the a click takes the user back to the main form.