Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subreport has no data - Print 'No data available' if empty 1

Status
Not open for further replies.

DAmoss

Technical User
Jul 23, 2003
169
GB
Hi,

Can someone explain how I go about printing 'No data available' in place of my subreport when it actuall returns no data?

I'm 99.9% sure that I need to use the 'On No Data' event, but what do I need to do?

Thanx in advance
 
I've tried what was shown, but I can't get the message to show up. I put a textbox in the subreport header as the answer suggested, with the following source:

=IIf([HasData],"Project","Currently no output data to display")

Any ideas as to what I'm doing wrong?
 
DAmoss, you might be better off using the Label as Samyers said,

samyers (TechnicalUser) 22 Mar 07 18:34
I've added a label lblNoDataMessage, "No data to display", then set the form properties OnNoData, =[lblNoDataMessage].[Visible]=True

Have you tried this?

Also, make sure you're selecting the subreport control on your main form, and NOT the subreport's properties itself.
 
I've tried the Label method and it doesn't work either.

I put the Label 'lblNoDataMessage' in the subreport header containing my error message, I set its visible property to false. I then pasted the following in the subform On No Data event:

=[lblNoDataMessage].[Visible]=True

Not sure aboutyour last comment, am I missing something here?
 
The control should not be located on the subreport. If the subreport won't display than any control on the subreport won't display. Place the control on the main report.

Try a text box in the main report with a control source of:
Code:
=IIf(SubrptCtrlName.Report.HasData, Null , "No data available")

Duane
Hook'D on Access
MS Access MVP
 
how about creating a macro called OnErrorDisplayMessage
and in that macro enter an action 'msgbox' with the message being "No data to display"
and another action 'CancelEvent'

Finally, in the 'On no data' event of the report put the name of the macro to be called in this case OnErrorDisplayMessage

works for me!


Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 
Cheers dhookom, I finally got it working after doing what you said, I should read more carefully next time.

ProgrammError, sorry but you appear to have strayed off the road, I don't want a popup error message, I wanted an error message printed on the report for each subreport that had no data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top