Results 1 to 12 of 12
  1. #1
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232

    IIF IsNull

    I have a form called invoices that I have a field in that is called Bill To.


    I would like the Bill To field to auto fill using information from the form customer.

    I have tried the following. =IIf(IsNull([Forms]![CUSTOMER]![Company/Owners Name]),[Forms]![CUSTOMER]![FIRSTNAME])

    if I remove the first part and just have the default =[forms]![customer]![firstname] it works but I need it to use the company/owners name if it is not null.

    Thanks Angie

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    IIF has 2 parts.

    Iif (some condition, true part, false part)
    I think you need
    =IIf(IsNull([Forms]![CUSTOMER]![Company/Owners Name]),[Forms]![CUSTOMER]![FIRSTNAME],[Forms]![CUSTOMER]![Company/Owners Name])

    The part in Green, is used if your criteria IsNull([Forms]![CUSTOMER]![Company/Owners Name]) is False

  3. #3
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Instead of
    =IIF(IsNull([Forms]![CUSTOMER]![Company/Owners Name]),[Forms]![CUSTOMER]![FIRSTNAME])

    I would use something like this
    =Nz([Forms]![CUSTOMER]![Company/Owners Name],[Forms]![CUSTOMER]![FIRSTNAME])

  4. #4
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232



    Thanks this did work and I wanted to add to it and when I did It would not work I think it has something to do with the chr(13) and chr (10) (to force a new line)
    here is what I tried. Thanks again Angie


    =IIf(IsNull([Forms]![CUSTOMER]![Company/OwnersName]),[Forms]![CUSTOMER]![FIRSTNAME] & " " &[Forms]![Customer]![LastName] & Chr(13) & Chr(10) &[Forms]![customer]![Street Number] & " " & [Forms]![customer]![Address]& Chr(13) & Chr(10) & [Forms]![customer]![City] & " "&[Forms]![customer]![state]![forms]![customer]![zip],[Forms]![customer]![Company/OwnersName])




  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,638
    Nz is still simpler. Missing & between state and zip.

    =Nz([Forms]![CUSTOMER]![Company/OwnersName], [Forms]![CUSTOMER]![FIRSTNAME] & " " & [Forms]![Customer]![LastName]) & Chr(13) & Chr(10) & [Forms]![customer]![Street Number] & " " & [Forms]![customer]![Address] & Chr(13) & Chr(10) & [Forms]![customer]![City] & " " & [Forms]![customer]![state] & " " & [forms]![customer]![zip]

    Why are you using the Forms! qualifier? If this textbox is on the same form as the fields/controls referenced in expression, the form name is not needed.

    Why even concatenate instead of separate textboxes?



    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.

  6. #6
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    You can replace Chr(13) & Chr(10). So if you had
    =Nz([Object],[Value1] & chr(13) & chr(10) & [value2])
    you could change it to
    =Nz([Object],[Value1] & vbcrlf & [value2])

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,638
    Unfortunately, vbCrLf does not work in textbox ControlSource nor in Access query object, it is a VBA constant.
    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.

  8. #8
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    This does not work the nz = the field shows #name?

    there is two forms I am pulling information from another form.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,638
    See posts 5 and 7.
    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.

  10. #10
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    "Orange"Thanks this did work and I wanted to add to it and when I did It would not work I think it has something to do with the chr(13) and chr (10) (to force a new line)
    here is what I tried. Thanks again Angie


    =IIf(IsNull([Forms]![CUSTOMER]![Company/OwnersName]),[Forms]![CUSTOMER]![FIRSTNAME] & " " &[Forms]![Customer]![LastName] & Chr(13) & Chr(10) &[Forms]![customer]![Street Number] & " " & [Forms]![customer]![Address]& Chr(13) & Chr(10) & [Forms]![customer]![City] & " "&[Forms]![customer]![state]![forms]![customer]![zip],[Forms]![customer]![Company/OwnersName])

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,638
    The Chr(13) & Chr(10) work just fine for me.

    You are still missing the & between state and zip. See post 5.
    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.

  12. #12
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Ok I had to correct a few things but I got the NZ code to work, thank you very much Angie

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

Similar Threads

  1. Using Between with iif isnull
    By TonyB in forum Queries
    Replies: 5
    Last Post: 09-03-2013, 09:56 AM
  2. IF IsNull set width to 0
    By Casey Sanders in forum Reports
    Replies: 7
    Last Post: 01-30-2013, 08:16 AM
  3. If Date IsNull
    By burrina in forum Forms
    Replies: 6
    Last Post: 01-10-2013, 07:23 PM
  4. If IsNull Value, Then need to be Zero
    By burrina in forum Forms
    Replies: 2
    Last Post: 11-18-2012, 02:53 AM
  5. IsNull
    By JJCHCK in forum Programming
    Replies: 3
    Last Post: 09-09-2011, 07:57 AM

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