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 
Random formula not working
Kim Wong 
     
2 years ago
I have a simple check. If Schedule Hours not = Contract Hours, display a message otherwise save the record.  Even though my schedule hours IS = to Contract Hours, it is saying it is NOT!  This is happening randomly, sometimes it is accurate, and it proceeds to save the record, sometimes its not. And I don't know what is triggering it.

Screenshots attached.
Kim Wong OP  @Reply  
     
2 years ago

Kim Wong OP  @Reply  
     
2 years ago

Sami Shamma  @Reply  
             
2 years ago
Msgbox the values you are comparing.
It is a very good chance that Null math is tripping you off
Kim Wong OP  @Reply  
     
2 years ago

Sami Shamma  @Reply  
             
2 years ago
This is also potentially rounding problem. The numbers you are seeing on the form rounded for display, but because of your calculations, the two numbers are not identical.
Display the numbers to four or even six decimal places
Kim Wong OP  @Reply  
     
2 years ago
I did do a msgbox of the values. they are showing the same values 30.4, 30.4.
Sami Shamma  @Reply  
             
2 years ago
Try and wrap Each of  the numbers with the Round Function.
Kim Wong OP  @Reply  
     
2 years ago

Kim Wong OP  @Reply  
     
2 years ago
I did a display up to 5 decimal points.  It showing the same numbers, but still giving me the message that they are not equal
Kim Wong OP  @Reply  
     
2 years ago
Where do I do a round,one number is coming from a form - is there a place I can specify it?
Sami Shamma  @Reply  
             
2 years ago
Did you Round them?
Sami Shamma  @Reply  
             
2 years ago
X = Round(value,2)

Y = Round(value1+value2+value3,2)
Kim Wong OP  @Reply  
     
2 years ago
I am looking it up now on rounding
Kim Wong OP  @Reply  
     
2 years ago
ah thanks, I will try it.
Kim Wong OP  @Reply  
     
2 years ago
Brilliant.  Worked!  Thanks soooo much!
Sami Shamma  @Reply  
             
2 years ago
You're most welcome
Kevin Yip  @Reply  
     
2 years ago
This is due to floating point errors that are inherent to computer chips.  Sometimes even simple math can't be done.  Use the immediate window to calculate 0.1 + 0.2 - 0.3 and you'll be shocked to see it's not zero (see picture below).  This has been an issue since the dawn of computers right up to today.  It's not really the fault of Access.  Until new computer chips are invented to fix this, it will always be an issue in all software that uses floating point math.
Kevin Yip  @Reply  
     
2 years ago

Kim Wong OP  @Reply  
     
2 years ago
Thanks for the additional insight, Kevin.

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: 5/9/2026 2:29:40 AM. PLT: 0s