Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 30th, 2005, 04:52 PM
Authorized User
 
Join Date: Aug 2005
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old October 30th, 2005, 05:05 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
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
Reply With Quote
  #3 (permalink)  
Old October 30th, 2005, 05:16 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Yorba Linda, California, USA.
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





Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:11 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.