Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    deepakg27 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    160

    Any way to show Zero in Place of Null in a query


    Hi guys,

    Was just wondering, is there any way to show zero in a field where the value is NULL, in a query. Later That query is to be used in report. If some how it can be achieved in report then also it is fine.

    Thanks and Regards
    Deepak Gupta

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Create an expression in your query using Nz function Nz(YourFieldName,0)
    Use that in your report as well
    Or set the default value =0
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    you might want to entertain the notion of making the table field default to zero, assuming this is about a table field in a query and not a calculated query field.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    You can format it in the report in the control properties if it's a number data type.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    deepakg27 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    160
    Hi Guys,

    Extremely Sorry, just realized my question was slightly wrong. Actually I have all fields with default value ZERO and after summing up gives Zero. But under certain criteria some times no records are found by the query and there it shows blank spaces in all the displayed fields. I want those fields also to be shown as zero, if possible.

    I am also not able to format it in report, cant find out where to do it. My data type is currency.

    Thanks and Regards
    Deepak Gupta

  6. #6
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Have a read here https://support.office.com/en-us/art...4-1fe286636668 for the Format options on the report control.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    Don't see how formatting will help. If the query result is no record(s) then there's nothing to format.
    No records in the entire report or just part of it? I think the latter - so i think the answer is conditional formatting if one is bent on a "fix", but you can only make it visible via shading/borders. If a control is bound to a query and there is no data in it you can't arbitrarily assign a value after it runs. The query itself would have to be modified, using a NZ expression in every field. IMHO this is more effort than it's worth as the current situation is quite normal.

  8. #8
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    The formatting can be made to a put 0 in the report so that the Report Grouping sum will still work, as will an export.
    I'm not sure if it's more efficient than an Nz() tbh, just an alternative method.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    As I mentioned, I don't consider this formatting. No data = nothing to format. It's more manipulating the value displayed in a control than it is formatting. At least that's my perspective and of course, you don't have to agree.

    While I think the first paragraph of the linked page supports my interpretation
    You have the data in a field appear in a specific format by applying custom formats. Custom formatting only change how the data is displayed and does not affect how the data is stored in a Microsoft Access database, or how users can enter or edit data.

    I am willing to learn any time from anyone. If you can point out where the page confirms that displaying data where there is none is also called formatting, then I will review it again.
    Thanks.

  10. #10
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Only that it's in a custom Format property.
    It's a very handy function on combo's for instance where you can get it to display "Enter a Value" when it's a numeric entry, instead of leaping through hoops to prompt the user by other means.

    I'm not disagreeing with you in any way, it's just an often overlooked method, that our very own wino moderator (Baldy) put me onto.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  11. #11
    deepakg27 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    160
    Dear Minty,

    could you please explain, what kind of custom formatting I need to create in order to show 0 in the report result box, if the value is null.

    Regards

  12. #12
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Deepak
    Did you try using Nz as I suggested in post #2
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  13. #13
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Quote Originally Posted by deepakg27 View Post
    Dear Minty,

    could you please explain, what kind of custom formatting I need to create in order to show 0 in the report result box, if the value is null.

    Regards
    It's explained here https://msdn.microsoft.com/en-us/vba...ncy-data-types

    But as others have said - the Nz([YourFIeld],0) may well be a better option.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  14. #14
    deepakg27 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    160
    Dear Ridders52,

    Yes I did try it. Please refer to my post #5.

    Regards

  15. #15
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Here is an example showing the use of Nz to get what you want.
    The attached db contains a table and report
    I've deliberately left some fields/records blank (null) so you can see that it works

    No formatting used in this example

    HTH
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 14
    Last Post: 03-25-2018, 01:13 PM
  2. Replies: 4
    Last Post: 03-11-2017, 09:48 PM
  3. Replies: 5
    Last Post: 03-08-2016, 07:25 AM
  4. Query Help - Show field if another field is null
    By lukekonrad in forum Access
    Replies: 1
    Last Post: 03-05-2012, 04:02 PM
  5. Do not show null records
    By brobb56 in forum Forms
    Replies: 1
    Last Post: 09-23-2011, 02:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums