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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

report displays nothing if no data is found

Status
Not open for further replies.

Guy999

Programmer
Apr 1, 2002
27
GB
Hi

In my report I have a query that counts entries in a table. The problem is that if there's no relevant entries in the table then nothing is displayed.

Is there a way to initialise the count at 0 before the report runs so that if nothing is found it will still display some text and the result of 0?

Thanks
Guy
 
In the NoData event of the report put a message box that tells the user that there is no data or record count = 0.
 
This is my standard lines of code in the NoData event of ANY report:


Private Sub Report_NoData(Cancel As Integer)
msgbox "The report has no data.", vbOKOnly + vbInformation
Cancel = True
End Sub


Some people need to visually see the code rather than explanation. I just thought I would add my 10 cents, because my 2 cents are free... :)

HTH
Roy McCafferty
aka BanditWk

Las Vegas, NV
roy@cccamerica.org
RLMBandit@aol.com (private)

"I do this because I know I can - no need to send gifts - just send me a smile to show me that I've helped." ~ seen on a cardboard sign held by Roy McCafferty on a corner in Las Vegas
 
Hi

My reports produce invoices which are then printed rather than just displayed on the screen, so this means that parts are missing if no data is found.

E.g. if the company has sent 10 messages this summary will be displayed in the invoice:

SMS Messages sent = 10
Email sent = 5


However if they haven't sent any sms messages that line will disappear - I need it to say 0 as default so the line will always appear in my printed invoice

SMS Messages sent = 0
Email sent = 5


Can I add these variables from a query into the nodata part and initialise them to 0?


Thanks for any help
Guy
 
I forgot to say that these summaries are in subreports in a main report
 
I did something a little bit different, but it might help. In my case, I am pulling a total off a subreport, but if there are no records on the subreport, it creates a #errror. I put this code in an unbound field on the main report. It tells that if there's an error to display 0.

=IIf(IsError([txtTotalOverdue]),"Total Overdue: 0",[txtTotalOverdue]) Linda Adams
Linda Adams/Emory Hackman Official Web site Official web site for actor David Hedison:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top