#Error when counting

  • Thread starter Thread starter Debbieag
  • Start date Start date
D

Debbieag

I've created a report to count the number of records that satisfy a
certain criteria. When the criteria is met, the count returns a
number. However, if the criteria is not met, the count returns #Error
instead of displaying a 0.

How do I fix this? If I can't get the report to actually print a 0,
then how about a pop up that informs the user that there are no
records?

TIA,
Deb
 
Hi,

Try the following:

=IIF([Report].[HasData]=True,Count([CustomerID]),0)

I hope this helps! If you have additional questions on this topic, please
respond back to this posting.


Regards,

Eric Butts
Microsoft Access Support

"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026."


--------------------
| From: Debbieag <[email protected]>
| Subject: #Error when counting
| Date: Mon, 19 Jan 2004 21:41:22 -0600
| Message-ID: <[email protected]>
| Organization: MSAccessForum.com
| User-Agent: MSAccessForum.com
| X-Newsreader: MSAccessForum.com
| X-Originating-IP: 67.75.27.24
| Newsgroups: microsoft.public.access.reports
| NNTP-Posting-Host: 69-56-172-122.theplanet.com 69.56.172.122
| Lines: 1
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.access.reports:128261
| X-Tomcat-NG: microsoft.public.access.reports
|
|
I've created a report to count the number of records that satisfy a
certain criteria. When the criteria is met, the count returns a
number. However, if the criteria is not met, the count returns #Error
instead of displaying a 0.
|
| How do I fix this? If I can't get the report to actually print a 0,
then how about a pop up that informs the user that there are no
records?
|
| TIA,
| Deb
 
I guess that you mean there are zero records returned by a query.

You can use the reports On No Data property to pop up a message box and cancel
the report.

Click the Events Tab of the Report.
Type Event Procedure in the On No Data line
Click on the ... at the end of the no data line and enter code that looks like:

Private Sub Report_NoData(Cancel As Integer)
Cancel = True
MsgBox "There are no records that meet the criteria", , "O Records"
End Sub

Close and save.

You could also open the report and show a label that says this and hide the
control(s) that display the data.
 
Back
Top