Rounding off Problam

G

Gobi

I have a problam on number rounding off. In using VBA in
Access.

I have an amount like .625. I wanted to round it to two
decimal points. if I do that the answer is .62.

Actualy My answer should be .63.

can please help me on this.
 
D

Denny G.

Add this code to a Module Object in your database
container:

Function Round(Value As Variant, Decimals As Integer)
If Decimals >= 0 Then
Round = Int(Value * 10 ^ Decimals + 0.5000001) /
10 ^ Decimals
Else
MsgBox ("Invalid amount of decimal places
supplied!")
Round = Value
End If
End Function


Add a text box to a report (based on a query with your
field you want to round) and in the Control Source for
that text box add this: =Round([the name of the field to
round in your query]/2,3)

Denny G.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top