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 2
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScDirectorAsked:
Who is Participating?
 
Gustav BrockConnect With a Mentor CIOCommented:
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.