How format function to round off figures

Hi

Is there a way to round off figures in ms access with the format function , for example

9.333 X 15.1111  =  141.0318963  now if I round off on the format property of a form to 2 decimal places  it gives me 141.03 , my control on the other subform require the users to balance off with this 141.0318963, if it does not balance off then the data on the form cannot be saved.

Because of the decimals remaining the data cannot be saved , then how do I format both controls so that if the users captures 141.03  not 141.0318963 the data can be saved

Regards

Chris
LVL 3
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScDirectorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
use the Round
Round(Amount,NoOfDecimals)

Open in new window

e.g.
amountToPay=Round(141.0318963,2)-->141.03

Open in new window

0
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScDirectorAuthor Commented:
Now if the round off number amountToPay=Round(141.0318963,2)-->141.03  if I subtract with  141.03 are you sure it wont leave some points?????


Regards

Chris
0
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScDirectorAuthor Commented:
Maybe I'm not clear here , what I want is that if the difference is between -0.5 and 0.50 then let the data maybe saved

If diff.txt ( between -1And 1) Then
MsgBox " Please clear the difference"
Cancel = True
Exit Sub
End If
End Sub

Now I'm not sure how the above can be polished up to work, please check.

Regards

Chris
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Use the Format property on both numbers in the comparison?
0
Gustav BrockCIOCommented:
Be aware, that the native Round is quite buggy, so if you want precise data, use the excellent rounding functions here:

Rounding values up, down, by 4/5, or to significant figures

I'm not sure what you ask about, though. If you wish to compare two values within two decimals, round both to two decimals.
Further, be sure to use data type Currency, not Double, and indeed not Single, when making such comparisons.

Thus, something like:

If CCur(RoundMid(9.333 * 15.1111, 2)) = CCur(14.03) Then
   ' Match.
End If

Open in new window

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.