Results 1 to 2 of 2
  1. #1
    ben_jamin is offline Novice
    Windows 8 Access 2013
    Join Date
    Jul 2013
    Posts
    4

    Setting a number field to Null instead of zero 0 in an update query


    Hello,
    I have an update query that calculates a value based on the value in another field. However, if the value in the other field is 0, the calculation does not work because you get division by zero 0. When the value in the other field is 0, I need the update query to put a null value in the calculated field. It cannot put a zero 0 there because a zero 0 has other meanings and would be incorrect. How can I set the calculated number field to be either blank or null or erased when the other field is 0? Thank you.

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    It would depend on the "required" setting for the field in the table. If Required = Yes, then you can't set it to Null.

    If required = No, then you could use an Update query with an Iif expression: iif(FieldA = 0, Null, fieldB / fieldA)

    to update the field.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 11-15-2014, 07:43 PM
  2. Update query to set null value lookup field
    By alexjose in forum Access
    Replies: 1
    Last Post: 06-24-2013, 04:26 PM
  3. Setting field to null
    By Daryl2106 in forum Access
    Replies: 15
    Last Post: 01-29-2013, 09:12 AM
  4. Null value in an auto-number field
    By mharkin in forum Import/Export Data
    Replies: 9
    Last Post: 10-03-2012, 07:43 AM
  5. Replies: 2
    Last Post: 05-30-2012, 10:38 AM

Tags for this Thread

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