Solved ROUNDUP NUMBERS (1 Viewer)

hatmak

Registered User.
Local time
Yesterday, 16:31
Joined
Jan 17, 2015
Messages
84
hi all



in excel to get round up number



like 325 ------ use roundup to do it like 330

how do it in access QUERY



iTEM Count

A 305 ------.> ROUND UP TO 310

B 209-------. ROUNDUP TO 210
 

Attachments

  • ROUNDUP_ACCESS.accdb
    484 KB · Views: 18

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:31
Joined
May 7, 2009
Messages
14,556
use Ceiling() function:

'https://www.tek-tips.com/faqs.cfm?fid=5031
Public Function Ceiling(ByVal X As Double, Optional ByVal Factor As Double = 1) As Double
' X is the value you want to round
' is the multiple to which you want to round
Ceiling = (Int(X / Factor) - (X / Factor - Int(X / Factor) > 0)) * Factor
End Function


?ceiling(305, 10)
?celing(209, 10)
 

hatmak

Registered User.
Local time
Yesterday, 16:31
Joined
Jan 17, 2015
Messages
84
could you please add to my example

it not work with me

regards
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:31
Joined
May 7, 2009
Messages
14,556
see Module 1.
see your query.
 

Attachments

  • ROUNDUP_ACCESS.accdb
    520 KB · Views: 27

ByteMyzer

AWF VIP
Local time
Yesterday, 16:31
Joined
May 3, 2004
Messages
1,400
use Ceiling() function:

'https://www.tek-tips.com/faqs.cfm?fid=5031
Public Function Ceiling(ByVal X As Double, Optional ByVal Factor As Double = 1) As Double
' X is the value you want to round
' is the multiple to which you want to round
Ceiling = (Int(X / Factor) - (X / Factor - Int(X / Factor) > 0)) * Factor
End Function


?ceiling(305, 10)
?celing(209, 10)
Hello, @arnelgp,

Thank you for the reference to my code (wow, that was a long time ago!)

I have since simplified it to the following:
Code:
Public Function Ceiling(ByVal number As Double, ByVal significance As Double) As Double
    Ceiling = Int(number / -significance) * -significance
End Function

Public Function Floor(ByVal number As Double, ByVal significance As Double) As Double
    Floor = Int(number / significance) * significance
End Function
 

isladogs

CID VIP
Local time
Today, 00:31
Joined
Jan 14, 2017
Messages
15,516
Crossposted at UtterAccess.com where Gustav Brock suggested what is essentially the same solution to ByteMyzer.
This is for use in a query, specifically rounding up to the nearest 10

Code:
-Int(-[YourField] / 10) * 10 As RoundUpValue
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:31
Joined
May 7, 2009
Messages
14,556
Hatmak will probably favor this forum. Why?
 

Users who are viewing this thread

Top Bottom