Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 18th, 2005, 12:07 PM
Authorized User
 
Join Date: Aug 2005
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default RoundUp function

Is there a function that allows roundup, for example if the price is 5.23 it will round UP to 5.30?

thanks

 
Old September 18th, 2005, 01:47 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

I think this will probably work - I haven't tested it yet though

For your problem, you would enter RoundUp(5.23, 1)

Public Function RoundUp(number As Double, significant As Integer) As Double
    RoundUp = Round(number, significant)
    If RoundUp < number Then
        RoundUp = RoundUp + (1 / (10 * significant))
    End If
End Function

You could then format the result using Format(5.3, "0.00")

Hope that helps,

Mike

Mike
EchoVue.com
 
Old September 18th, 2005, 07:19 PM
Authorized User
 
Join Date: Aug 2005
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it seems to work thanx

 
Old September 23rd, 2005, 10:04 PM
Authorized User
 
Join Date: Aug 2005
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

now I will like the RoundUp function to ignore Null values

thanks

 
Old September 27th, 2005, 12:04 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You could try adding...

If Not IsnNull(number) then
  <Function Code>
Else
   RoundUp = 0 'Or whatever value you would like
End if
End Function

Mike
EchoVue.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Math Calculations, Roundup Apocolypse2005 VBScript 0 May 25th, 2007 04:27 PM
send variable in function to another function schoolBoy Javascript How-To 6 March 3rd, 2007 09:16 AM
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
roundup function conflict with null values mjuliao Access 2 October 30th, 2005 05:16 PM
retreive function/Line from macro or function? MikoMax J2EE 0 April 1st, 2004 04:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.