Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Access Divide by Zero Error
Mubeezi Micah 

15 years ago
Dear Richard,

In Excel, there is an IFERROR function that one could use to trap Divide By Zero Errors. Is there an equivalent function in Access?
In one of my reports, i have to calculate percentages. However, if  there are no records in the parameters supplied to the query, i get a Num# error in some textboxes in the report. So far, i am using an ad hoc solution. It first checks if the denominator will be a zero before the division can take place as shown below;
=IIf([TotalPatients]=0,0,[ChildrenOnly]/[TotalPatients])

Is there a better way that i could do this? I have heard of HasData property but i have failed to get it to work for a textbox.

Please advice me

MICAH



Reply from Richard Rost:

As far as I know there is no IFERROR function in Access or VBA. It's an Excel-only function.

There is an "On No Data" event for each report. It will fire if there are no records. You can then make your code gracefully abort the report load. Something like:

MsgBox ("There are no records to show.")
Cancel = 1

Aside from that, your solution is fine... or you could run a DLOOKUP before you launch the report (in the button code, perhaps) to check TotalPatients.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/17/2026 7:05:46 AM. PLT: 1s