Results 1 to 5 of 5
  1. #1
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,038

    IIF with wildcard in Report

    ExExperts:

    I'm 100% confident there's a very simply solution to my problem. However, I'm always getting syntax errors when attempting to add a wildcard "*" (before and after) a string value.

    For example, in my Access report, I may have the following three names in the last name column:
    Smith
    Smithfield
    Henderson-Smith

    When using =Sum(IIf([All_LastName]="Smith",1,0)) in my control, obviously a value of 1 is returned. Instead I want to add wild cards so that the SUM value returns 3.

    I tried =Sum(IIf([All_LastName]=Like "*" & "Smith" & "*",1,0))... (as well as other variations) but apparently Access doesn't like the syntax.

    What's the proper syntax so that the SUM returns a value of three?

    Thank you,
    EEH

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Don't use = sign in front of LIKE.

    =Sum(IIf([All_LastName] Like "*Smith*",1,0))
    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
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,038
    Ah... I knew it was something simple... thank you June7. That did the trick.

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Tom,

    Wildcard examples here and often in the Similar Threads at the bottom of a thread.

  5. #5
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,038
    orange -- thank you for the link to some wildcard examples... 'much appreciated.

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

Similar Threads

  1. wildcard charcters
    By lawdy in forum Programming
    Replies: 19
    Last Post: 05-21-2018, 04:11 AM
  2. Wildcard Join???
    By mindbender in forum Queries
    Replies: 3
    Last Post: 04-30-2018, 12:34 PM
  3. Replies: 9
    Last Post: 12-05-2013, 11:48 AM
  4. Open report with wildcard where conditioon
    By hithere in forum Reports
    Replies: 3
    Last Post: 12-18-2012, 10:19 PM
  5. Querying a wildcard
    By undee69 in forum Queries
    Replies: 1
    Last Post: 10-15-2012, 06:00 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