Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
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 October 30th, 2005, 04:52 PM
Authorized User
 
Join Date: Aug 2005
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default roundup function conflict with null values

I have this function:

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

The problem is that when a txtA has a Null value then txtB = RoundUp([txtA],2) = #ERROR, instead of #ERROR I will like it to be Null too. I have tried the NZ function but it doesn't converts #ERROR to Null.

Please help.
Thanks

 
Old October 30th, 2005, 05:05 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Try this...

txtB = iif(isnull(txtA), Null, RoundUp([txtA],2)

I think that should work, if not let me know and we can try and figure something else out.

Mike

Mike
EchoVue.com
 
Old October 30th, 2005, 05:16 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 217
Thanks: 0
Thanked 1 Time in 1 Post
Default

mjuliao,
It looks like textbox B needs textbox A's value so it can calculate its own value?

Did you try using NZ against txtA and putting the result into a variable? Use NZ when you take the value OUT of a control to force the value to either "" if it is a string or 0 if a numeric. You'll probably want to set the format of the txtbox to "general number" so your user doesn't enter text and create other problems with your function).

HTH,

LOralee










Similar Threads
Thread Thread Starter Forum Replies Last Post
Null values jmcgranahan BOOK: Access 2003 VBA Programmer's Reference 0 August 29th, 2006 02:25 PM
CheckBoxList and Null Values steve35719 ASP.NET 2.0 Basics 1 April 21st, 2006 09:42 AM
Handling Null Values ~Bean~ ASP.NET 1.x and 2.0 Application Design 1 January 31st, 2006 02:02 PM
Handling Null Values nvenkat75 ADO.NET 2 January 16th, 2006 05:46 PM
RoundUp function mjuliao Access 4 September 27th, 2005 12:04 PM





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