Results 1 to 6 of 6
  1. #1
    dhborchardt is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Posts
    7

    If value is zero use county name

    I have data where some of the zip codes are not given. In that case I need to go by the county name which is another field in the record. Can I just use some sort of If then expression?
    ZIPCODE: If [zipcode] = 0 then [CountyName] else [zipcode].


    Sorry Access query expressions are not my strong suit.
    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    IIf([zipcode]=0,[CountyName],[zipcode])

    Does the field have a 0 value? Or is it actually Null?

    Nz([zipcode],[CountyName])
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    dhborchardt is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Posts
    7
    I am getting #Error on all zip codes regardless of 0 or actual zipcode. I could give you a screen shot showing the query, the result and the table that is being queried but I don't see how to attach.

    Your second question: The original data came in a text file with the word Null. I am guessing that would be handled as text so I did a replace all and used 0.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Attachment manager is below the Advanced Post editor. Click Go Advanced below the Quick Reply editor.

    Where did you use the expression?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    dhborchardt is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Posts
    7
    I figured it out. The 0 is text so I added "s.
    IIf([zipcode]="0",[CountyName],[zipcode])
    Thanks again.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Of course, I should have realized that. Glad you figured it out.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. County Search Help!
    By BuzzBamm101 in forum Forms
    Replies: 2
    Last Post: 12-21-2011, 01:25 PM
  2. Normalizing various City/County/State combinations (w/out zip)
    By DorkyDuvessa in forum Database Design
    Replies: 2
    Last Post: 05-08-2011, 07:49 PM
  3. Replies: 1
    Last Post: 03-15-2010, 02:52 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