Solved

Convert Null to 0

Posted on 2004-09-22
4
666 Views
Last Modified: 2008-02-01
Hi all,

How do I convert null to 0 in Access?

Thanks,

Adi
0
Comment
Question by:vbtiger
  • 2
  • 2
4 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12120383
Nz([YourField],0)
0
 
LVL 1

Accepted Solution

by:
AJ_UK earned 50 total points
ID: 12121299
that works for variables of type "Variant", but for others the following will work:

IIf(IsNull([YourField]), 0, [YourField])

Cheers,
AJ
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12123205
Only a Variant can hold Nulls.
0
 
LVL 1

Expert Comment

by:AJ_UK
ID: 12123747
Sorry, I meant "others" to mean other situations, not other variable types. Data fields can hold null values, and both queries and recordset manipulation sometimes need to avoid or manipulate null values encountered.  Not sure where Adi was working in Access.
Best to convert any null data values when assigning to other than "variant" type variables--like you said, only variant can hold null, so other variable types will give error on assignment of null.
AJ
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now