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

    remove & if no data

    I use the following as a default value in a text box


    If there is no “spouse” name I would like the & to notshow.
    The way it is now it would show “ first name & last name


    =[Forms]![Customer]![FirstName] & " & "& [Forms]![Customer]![Spouse] & " " &[Forms]![Customer]![LastName]

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    If the field is Null:

    =[Forms]![Customer]![FirstName] & (" & " + [Forms]![Customer]![Spouse]) & " " &[Forms]![Customer]![LastName]

    which takes advantage of the fact that + propagates Nulls.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    There are several ways of solving this including
    1. Using If...Else... End If where the if condition is Nz(Spouse,"")<>""

    2. Replacing the Spouse part with an Nz statement

    3. Using + instead of & to concatenate the & Spouse part
    Code:
    [firstName] & " & " + [Spouse] & " " & [LastName]
    Method 3 is probably simplest

    EDIT: Paul got there first
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  4. #4
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Thank you, that worked just how I needed it to.....

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

Similar Threads

  1. Remove range of data from query
    By jaccess in forum Queries
    Replies: 2
    Last Post: 02-01-2018, 03:00 PM
  2. Remove data if field value is zero
    By tombarberio in forum Queries
    Replies: 6
    Last Post: 10-28-2014, 04:45 PM
  3. Replies: 3
    Last Post: 10-04-2013, 06:24 AM
  4. Use database to remove data from another?
    By James_ in forum Access
    Replies: 8
    Last Post: 01-23-2012, 09:49 AM
  5. Remove Quotes within Data Values
    By kfschaefer in forum Programming
    Replies: 0
    Last Post: 02-26-2009, 01:15 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