on no data - need to show SOMETHING

D

DavPet

I have a group of 5 reports. 3 of the 5 often have nothing to report.
I use Cancel=True in the On NoData event for the reports because whene there
is no data, several of the report fields say "Error".
I want the report to print the phrase "No data for this report" and not see
any of the errors in the empy fields.

How ??
 
M

Marshall Barton

DavPet said:
I have a group of 5 reports. 3 of the 5 often have nothing to report.
I use Cancel=True in the On NoData event for the reports because whene there
is no data, several of the report fields say "Error".
I want the report to print the phrase "No data for this report" and not see
any of the errors in the empy fields.


Using the NoData event to cancel a subreport has no
signiicant effect because a subreport with no data will not
do anything.

A mainreport text box can check if a subreport has no data
and display whatever you want by using an expression like:

=IIf(subreport.Report.HasData,
subreport.Report.subreporttextbox, "No data for this
report")
 
T

tina

so you want a page to print for a report even if there is no data? if so,
here's one solution:

in each report's Design view, add a Label control, i'll call it "Label6".
you'll have to type something in it so it will "stick" - it doesn't matter
what. in the Properties box, set the label's Visible property to No.
in each report's NoData event procedure, remove the "Cancel = True" code.
replace it with the following, as

Dim ctrl As Control

For Each ctrl In Me.Controls
If ctrl.Name = "Label6" Then
ctrl.Caption = Me.Caption & " has no data."
ctrl.Visible = True
Else
ctrl.Visible = False
End If
Next ctrl

if there's no data, all controls in the report will be hidden, and the
Label6 control will be unhidden. the report will print (or preview)
normally.

hth


 
D

DavPet

Thanks. This is what I wanted.


tina said:
so you want a page to print for a report even if there is no data? if so,
here's one solution:

in each report's Design view, add a Label control, i'll call it "Label6".
you'll have to type something in it so it will "stick" - it doesn't matter
what. in the Properties box, set the label's Visible property to No.
in each report's NoData event procedure, remove the "Cancel = True" code.
replace it with the following, as

Dim ctrl As Control

For Each ctrl In Me.Controls
If ctrl.Name = "Label6" Then
ctrl.Caption = Me.Caption & " has no data."
ctrl.Visible = True
Else
ctrl.Visible = False
End If
Next ctrl

if there's no data, all controls in the report will be hidden, and the
Label6 control will be unhidden. the report will print (or preview)
normally.

hth
 

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

Top