Results 1 to 7 of 7
  1. #1
    atlee is offline Novice
    Windows 8 Access 2013
    Join Date
    Feb 2014
    Location
    London, England
    Posts
    2

    Using a wildcard if an IIF statement.

    Hi Everyone



    Could somebody please help me out with the following: How do I use a wildcard in an expression on a form? E.g. If a postcode is either CR0 4** or CR0 3** I want it to return a value of "Beddington North"? So far I have tried: =IIf([Post Code]="CR0 3AR","Beddington North") but this obviously only returns Beddington North if its an exact match. I have tried substituting the AR for * but then I get no return.

    Grateful for any help.

    Thanks
    andrea

  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,521
    Try

    =IIf([Post Code] Like "CR0 3*","Beddington North")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    atlee is offline Novice
    Windows 8 Access 2013
    Join Date
    Feb 2014
    Location
    London, England
    Posts
    2
    Thanks so much, perfect. What do I use if I want it to use CR0 3* or CR0 4*?

  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,521
    =IIf([Post Code] Like "CR0 3*" Or [Post Code] Like "CR0 4*","Beddington North")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Works without the not true argument?

    =IIf([Post Code] Like "CR0 3*" Or [Post Code] Like "CR0 4*", "Beddington North", Null)
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Why don't you test? I did.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Okay, why does it work (defaults to Null) with LIKE and wildcard but = generates 'wrong number of arguments'? Guess I've never used LIKE and wildcard in a textbox expression.

    Correction, now I'm not getting the error even with = expression!!%? Don't know what I did different.

    Suppose I've always automatically included the False argument.

    Learn something new!
    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.

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

Similar Threads

  1. Replies: 9
    Last Post: 12-05-2013, 11:48 AM
  2. Replies: 2
    Last Post: 04-04-2013, 03:13 PM
  3. Querying a wildcard
    By undee69 in forum Queries
    Replies: 1
    Last Post: 10-15-2012, 06:00 AM
  4. Filter with wildcard
    By gg80 in forum Programming
    Replies: 8
    Last Post: 10-07-2011, 06:29 PM
  5. If OR statement (maybe a wildcard?)
    By Lorlai in forum Queries
    Replies: 5
    Last Post: 07-27-2011, 10:21 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