No Data-event and errorhandling

  • Thread starter Thread starter Henrootje
  • Start date Start date
H

Henrootje

Is it a good idea to write a module with a public function what to do
when a report is empty?


e.g.

Public Function EmptyReport()

msgbox "this report has no data and will not be opened"
other things I would like to do (like write to a logfile)

end function

My idea is that in that case on every report in the No Data event I
will only have to call the function EmptyReport() to have a uniform
action.

Would this be a good idea? If not, can anyone explain to me why not?


TIA!
 
Hi Henrootje,

Based on a tip published by Access MVP Allen Browne, I'd say you are fine to
do this. See item # 6 in the section titled "A default report" on this page:

Default forms and reports
http://allenbrowne.com/ser-43.html


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Is it a good idea to write a module with a public function what to do
when a report is empty?


e.g.

Public Function EmptyReport()

msgbox "this report has no data and will not be opened"
other things I would like to do (like write to a logfile)

end function

My idea is that in that case on every report in the No Data event I
will only have to call the function EmptyReport() to have a uniform
action.

Would this be a good idea? If not, can anyone explain to me why not?


TIA!
 
Hear hear!
Seems like I had a good idea for once :p

Thanks for the link Tom!!

Henro

Tom Wickerath schreef:
 
Actually, the Access group was several versions ahead of you. the
Report's NoData event was present in Acc97, maybe earlier.

The NoData event occurs after Microsoft Access formats a report for
printing that has no data (the report is bound to an empty recordset),
but before the report is printed. You can use this event to cancel
printing of a blank report.

That saves your having to write a function but you still need to call
your message box from within the event.

from one of my Acc97 apps:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The report has no data." _
& "@Printing the report is canceled. " _
& "@There may be no Transcripts for the Practitioners and
Dates " _
& "you selected. ", vbOKOnly + vbInformation
Cancel = True
End Sub

HTH
 
I know that Larry, the idea was to have that messagebox (or any other
consequent actions) in a module so the module would contain:

Public Function EmptyReport()
MsgBox "The report has no data." _
& "@Printing the report is canceled. " _
& "@There may be no Transcripts for the Practitioners and Dates
"
& "you selected. ", vbOKOnly + vbInformation
Cancel = True
End function

In all the reports the NoData event would only contain:

Private Sub Report_NoData(Cancel As Integer)
Call EmptyReport()
End Sub

An empty report would be created with things like this added and then
using that report as a template one is done quickly and easily.

Grtz H.
 
Hi Henro,
In all the reports the NoData event would only contain:
Private Sub Report_NoData(Cancel As Integer)
Call EmptyReport()
End Sub

If you use Allen Browne's method, you can call your public function without
having any VBA code behind the report. Allen's example showed this:

=NoData([Report])

In your case, this would look like this:

=EmptyReport([Report])

You do this by making a call to your EmptyReport function using the
Properies dialog, with the Event tab selected. You would need to modify your
EmptyReport function to accept a parameter.

For the record, I was also a bit confused by Larry's post.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

I know that Larry, the idea was to have that messagebox (or any other
consequent actions) in a module so the module would contain:

Public Function EmptyReport()
MsgBox "The report has no data." _
& "@Printing the report is canceled. " _
& "@There may be no Transcripts for the Practitioners and Dates
"
& "you selected. ", vbOKOnly + vbInformation
Cancel = True
End function

In all the reports the NoData event would only contain:

Private Sub Report_NoData(Cancel As Integer)
Call EmptyReport()
End Sub

An empty report would be created with things like this added and then
using that report as a template one is done quickly and easily.

Grtz H.
 
I did it exactly the way you described it and it works like a charm. I
am implementing this even in more situations (errorhandling where
appropriate)


Grtz H.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top