Results 1 to 8 of 8
  1. #1
    deso is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2013
    Location
    brisbane, australia
    Posts
    23

    convert zero to NULL

    I need to convert zero values to NULL values (yes, I definitely need to do it!).

    I am trying



    INSERT TABLEA.COLUMN1 = IIf([TABLEA.COLUMN1]=0,NULL)

    but this doesn't work. Any ideas?

  2. #2
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209

    convert zero to NULL

    You need an Update Query, rather than an Append Query, for what you are trying to do. You are trying to change all existing 0 values in COLUMN1 to Null. Use the following sample code:

    Code:
    UPDATE TABLEA SET TABLEA.COLUMN1 = NULL
    WHERE (((TABLEA.COLUMN1)=0));
    If you are trying to APPEND records and want NULL value as default in COLUMN1 then display the structure of TABLEA and set COLUMN1's DEFAULT VALUE property to NULL.

  3. #3
    deso is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2013
    Location
    brisbane, australia
    Posts
    23
    Thanks for offering to help apr pillai, however, that doesn't work. I get "data type mismatch in criteria expression". I can't find any errors/mismatch in the SQL. Any ideas?

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Post your SQL. It worked for me.

    My test SQL
    Code:
    UPDATE Calcs SET Calcs.Contract_ID = Null
    WHERE (((Calcs.Contract_ID)=1));

  5. #5
    deso is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2013
    Location
    brisbane, australia
    Posts
    23
    Hi ssanfu, I literally used apr pillai's SQL:

    UPDATE TABLEA SET TABLEA.COLUMN1 = NULL
    WHERE (((TABLEA.COLUMN1)=0));

    I was having problems when i converted that SQL into one that suited my table, so I copied the table, changed its name to TABLEA and the relevant column to COLUMN1. A box pops up first to ask me for parameter...I typed NULL, and get the mismatch error. But when I was converting the SQL to use in the original table, i was getting the mismatch error also. The field type of the column is text...is that a problem? If i convert it to number in datasheet view the values completely change.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If the field is text, then you need to use the proper delimiters.
    A number zero (0) is not the same as a text zero ("0").

    You shouldn't get a dialog box asking for a parameter. It means something is misspelled... check your field names.

    Try this SQL
    Code:
    UPDATE TABLEA SET TABLEA.COLUMN1 = NULL
    WHERE (((TABLEA.COLUMN1)="0"));

  7. #7
    deso is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2013
    Location
    brisbane, australia
    Posts
    23
    There's no spelling errors i can see. I've resaved the tables, started with fresh SQL. I'm using this SQL:

    UPDATE 4_GEO_LITHO_BORES SET 4_GEO_LITHO_BORES.TOP = NULL
    WHERE (((4_GEO_LITHO_BORES.TOP)="0"));

    4_GEO_LITHO_BORES is the table name, and "TOP" is the column name.

    I'm getting this error: syntax error in query expression (((4_GEO_LITHO_BORES.TOP)="0"))

  8. #8
    deso is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2013
    Location
    brisbane, australia
    Posts
    23
    guys, i've sorted this out with excel. I think there was an issue with the field values being text. so i converted to cvs., then converted cells to numbers, and sorted in excel and put it back in access. thanks anyway.

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

Similar Threads

  1. If/Then Null based on Null Value of Another Field
    By vbpeterson in forum Queries
    Replies: 11
    Last Post: 06-05-2012, 05:00 PM
  2. Replies: 1
    Last Post: 02-23-2012, 02:27 PM
  3. Finding the Max Date and Null Values if Null
    By SpdRacerX in forum Queries
    Replies: 1
    Last Post: 02-03-2012, 06:29 AM
  4. Update field1 if Null, if Not Null update field2
    By mfirestorm in forum Queries
    Replies: 2
    Last Post: 12-02-2011, 09:51 AM
  5. Convert null to "" in Access
    By isaac_2004 in forum Access
    Replies: 1
    Last Post: 12-04-2009, 06:50 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