Solved ROUNDUP NUMBERS (1 Viewer)

hatmak

Registered User.
Local time
Today, 15:30
Joined
Jan 17, 2015
Messages
121
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: 74

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:30
Joined
May 7, 2009
Messages
19,169
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
Today, 15:30
Joined
Jan 17, 2015
Messages
121
could you please add to my example

it not work with me

regards
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:30
Joined
May 7, 2009
Messages
19,169
see Module 1.
see your query.
 

Attachments

  • ROUNDUP_ACCESS.accdb
    520 KB · Views: 83

ByteMyzer

AWF VIP
Local time
Today, 15:30
Joined
May 3, 2004
Messages
1,409
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

MVP / VIP
Local time
Today, 22:30
Joined
Jan 14, 2017
Messages
18,186
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
Tomorrow, 06:30
Joined
May 7, 2009
Messages
19,169
Hatmak will probably favor this forum. Why?
 

Users who are viewing this thread

Top Bottom