Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72

    transform zero values into null (blank)

    Hi everyone,



    How do I transform zero values = 0 into null values automatically?

    For example: I introduce in my field called age -> 0 *automatically age becomes "null" (in blank)

    I tried to open the table in Design View and use Format located in the Field Properties.

    Unfortunately, this "simple" task is not so easy to do.

    Any ideas?


    Thanks in advance.
    Last edited by mar7632; 03-06-2019 at 05:13 AM. Reason: spelling

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,128
    Remove the default value of 0 from that number field in design view.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    The point is that I want to avoid to introduce zero values in my form.

    If Any value is introduced as zero = 0, then it shows null or blank

  4. #4
    Minty is online now VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    If it is a number field it can't be blank "" or ZLS , it can only be 0 or Null.

    As Colin pointed out if you remove the default value, then simply put validation on the forms to not allow 0 to be entered, (do it in the forms before update event.)
    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
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Thank you for your response,

    I want to set a rule in which zero values are equal to null. Zero values can be introduced in my form by my co workers. I know that you can put validation on the form to not allow 0 to be entered, but for my application it does not work.

  6. #6
    Minty is online now VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    I don't understand why that wouldn't work. If you prevent them entering 0 then you avoid the problem, how can that not work?

    The other route would be to use a combo box with all possible number values without 0 and use that as a control, but it seems overkill and messy especially if your values could be over a very large range of inputs ?

    In the after update event a simple check of

    If Me.MyControl = 0 then Me.MyControl = Null

    would probably work, but confuse the hell out of the end user...
    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
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    If Any value is introduced as zero = 0, then it shows null or blank
    your requirement isn't very clear. Do you want to 'show' a blank for zero in your form? or do you want to store nulls instead of zeros in the table
    have you considered using the format property? for numbers you can have 4 different formats

    positive;negative;zero;null

    so
    0;0;""

    will show a 'blank' for 0 values (but will store a zero in the table)

  8. #8
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Sorry, I know that the information I am providing is poor. But it's a long story haha.

    Thank you for all your comments, specially Ajax's comment which is the key point and what I want from the beginning.

  9. #9
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    I´ve been updating for each field I have in my table this format 0;0;"" But only it works with date and number fields. How do I set this property in text fields?

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,128
    Perhaps I'm being dense but why can't you use one of the setups below?

    Click image for larger version. 

Name:	Capture.PNG 
Views:	18 
Size:	228.5 KB 
ID:	37715
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  11. #11
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    The reason why I can not use the setup you show is that most of the data I Introduce in my access database is by using an export from excel which I receive from my cowokers. Some of the values from excel (which I am not allow to edit) are zeros. For me it is a little bit annoying to perform a update query every week, so I prefer to set this function in a easy way without using too much code.

  12. #12
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    How do I set this property in text fields?
    text fields only have two format conditions - any text value or null. So not clear what you are trying to do. if you mean zeros in a text field, it won't work

    see this link about the format property https://docs.microsoft.com/en-us/off...textbox.format

  13. #13
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,128
    Rather than import your Excel values direct into your table, first import into a temporary or 'buffer' table and do your processing there to remove zeroes, THEN import to your final table
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  14. #14
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,706
    Some of the values from excel (which I am not allow to edit) are zeros.
    Colin's suggestion is what I like. Indeed you cannot edit a linked spreadsheet, but you can edit an appended table to your heart's content.

  15. #15
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Hi everyone,

    Thank you for all your comments and sorry for not answering before. How do I import into a temporary "buffer" table? What are the steps?

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

Similar Threads

  1. If Blank or Null Grab Previous Value
    By Kaloyanides in forum Queries
    Replies: 3
    Last Post: 01-16-2019, 05:37 PM
  2. Remove Blank Space if Null
    By laniebe in forum Reports
    Replies: 3
    Last Post: 04-27-2017, 01:01 AM
  3. Transform Column values in Table
    By Mnelson in forum Access
    Replies: 1
    Last Post: 06-11-2012, 03:06 PM
  4. Finding the Max Date and Null Values if Null
    By SpdRacerX in forum Queries
    Replies: 1
    Last Post: 02-03-2012, 06:29 AM
  5. Null field blank
    By brobb56 in forum Reports
    Replies: 3
    Last Post: 09-26-2011, 12:15 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