Results 1 to 4 of 4
  1. #1
    theosgood is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Location
    Denver, CO
    Posts
    30

    field concatenation on a form

    I am building a form in Access 2007. I have 5 fields that when concatenated populate a 6th field, Offer Desc.



    Code:
    =IIf([Item Promo Price]=0,IIf([Category Discount]=0,Format([DollarOff],"Currency"),Format([Category Discount],"0%")),Format([Item Promo Price],"Currency"))+"; "+[Gender]+" "+[VendorName]+" "+[ModelNumber]+" "+[ItemDesc]
    This works perfectly if all fields are populated, if any one of the fields is null, then Offer Desc is null.

    I tried IIf([ModelName]=Null," ",[ModelNumber]). I added a sub to each of the 5 fields to refresh on lost focus. I've tried setting the default value for the fields to " ". No luck. Suggestions please.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    You're running into a handy quirk that can be used to your advantage. + as a concatenation operator propogates Null's; & does not.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    theosgood is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Location
    Denver, CO
    Posts
    30

    Thumbs up

    Thanks Paul. That solved the problem. Nice little concatenation tidbit to store away.

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    No problem. & is the "standard" concatenation operator, but creative use of + can be helpful when you only want to include one part when another part isn't Null.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Field concatenation
    By Trojnfn in forum Access
    Replies: 1
    Last Post: 10-10-2011, 05:56 PM
  2. Query and Concatenation
    By Try2Live4God in forum Programming
    Replies: 2
    Last Post: 05-25-2010, 03:45 PM
  3. Concatenation of Text and Number
    By diane802 in forum Reports
    Replies: 67
    Last Post: 01-26-2010, 03:37 PM
  4. Concatenation Urgent Help
    By Shoaib in forum Queries
    Replies: 0
    Last Post: 04-23-2009, 11:02 PM
  5. Concatenation, nested IIF functions
    By krymer in forum Queries
    Replies: 2
    Last Post: 10-20-2008, 07:27 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