Results 1 to 6 of 6
  1. #1
    cliff.clayman is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    55

    How to add a an additional condition to this expression

    I have an expression to pull the last name from a full name field that is typically formatted like last name, first name. However, in a couple of examples, I have a company name that contains no commas. How can I add an additional condition to the expression below to just return the full name value when there is no comma present?

    Left([Names],InStr(1,[Names],",")-1)

  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,643
    Use an IIf(), testing with InStr() for a comma. Return the full string if none, your expression otherwise.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    cliff.clayman is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    55
    I understand the concept, can you help with the code itself?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    IIf(InStr(...) > 0, YourExpression, FieldName)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    cliff.clayman is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    55
    Thank you!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    No problem!
    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. Adding a 3rd condition in IIf(IsNull expression
    By Holli in forum Programming
    Replies: 2
    Last Post: 05-20-2015, 01:04 PM
  2. Additional UI controls
    By arikamir in forum Access
    Replies: 1
    Last Post: 05-05-2015, 10:14 AM
  3. additional pages
    By snoopy in forum Reports
    Replies: 3
    Last Post: 06-15-2012, 02:06 AM
  4. to add additional tables or not?
    By phineas629 in forum Database Design
    Replies: 1
    Last Post: 09-30-2011, 12:23 PM
  5. Adding an additional WHERE clause
    By Pells in forum Queries
    Replies: 7
    Last Post: 10-28-2010, 12:44 PM

Tags for this Thread

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