What is the best command syntax to use to determine if a number is evenly divisible by 3.00
9.00 / 3.00 = 3 is OK
8.00 / 3.00 = 2.66 NG
10.00 / 3.00 = 3.33 NG
Thanks, John
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Evenly Divisible By a Number? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)
Having problems with following logic”
The 1st MsgBox = 9 and 2nd MsgBox = 3 is triggering
MsgBox “Current Price dose not contain the proper surcharge: ” path,
Shouldnโt it trigger
MsgBox “Current Price look OK: ”
What am I doing wrong?
Thanks
John
Private Sub curPrice_BeforeUpdate(Cancel As Integer) โthis reveals 9 MsgBox (Nz(Me.curPrice, 0) _ - Nz(Me.curAmount, 0)) _ + Nz(DLookup("[curSurcharge]", "[tbl_RevGLDesc]", _ "[lngRevGLDescID] = RC "), 0) โthis reveals 3 MsgBox Nz(DLookup("[curSurcharge]", "[tbl_RevGLDesc]", _ "[lngRevGLDescID] = RC "), 0) If (Nz(Me.curPrice, 0) _ - Nz(Me.curAmount, 0)) _ + Nz(DLookup("[curSurcharge]", "[tbl_RevGLDesc]", _ "[lngRevGLDescID] = RC "), 0) _ Mod _ Nz(DLookup("[curSurcharge]", "[tbl_RevGLDesc]", _ "[lngRevGLDescID] = RC "), 0) = 0 Then MsgBox "Current Price look OK: " Else MsgBox "Current Price dose not contain the proper surcharge: " Cancel = True Exit Sub
You probably have to place the parentheses differently:
If (Nz(Me.curPrice, 0) _ - Nz(Me.curAmount, 0) _ + Nz(DLookup("[curSurcharge]", "[tbl_RevGLDesc]", _ "[lngRevGLDescID] = RC "), 0)) _ Mod _ Nz(DLookup("[curSurcharge]", "[tbl_RevGLDesc]", _ "[lngRevGLDescID] = RC "), 0) = 0 Then MsgBox "Current Price look OK: "
If that doesn’t work either, it may be caused by rounding problems.
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.