Results 1 to 6 of 6
  1. #1
    Lorlai is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    107

    If OR statement (maybe a wildcard?)

    I'm having some problems with my access query. I have an if statement, but can't seem to incorporate an OR statement to work properly. Or even the wildcards.

    I have my table with my information, including a field called [Pro_Status]. From this field, I want to create an if statement; if Active or Program Active, then display "yes".

    I have the following code, which works great for just one of the options (either "active" or "program active":
    Code:
    Active: IIf([Pro_Status]="Active","Yes"," ")
    I've tried to create an OR statement:
    Code:
    Active: IIf([Pro_Status]="Active" OR "Program Active","Yes"," ")
    And had nothing happen. I've also tried to incorportate wildcards("*Active") and ("%Active") and couldn't get any of them to work. Does anyone have advice about this? How can I make this if statement work?




    Thank you!!

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    It would be:

    Code:
    Active: IIf([Pro_Status]="Active" OR [Pro_Status] = "Program Active","Yes", Null)

  3. #3
    Lorlai is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    107
    Once again Bob, you are my knight in shining armor! Thank you thank you!

  4. #4
    bryenton is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    2
    Hi Bob,
    What if the field [Pro_Status] has multiple values with commas? Can I add the wildcard in that instance.... my example would be...

    IIf([CONSOURCES]="AL" Or [CONSOURCES]="ALS" Or [CONSOURCES]="ALN","ALUMNI","NONALUMNI")

    My statement is not working because the CONSOURCES field contains data lists like "FS, AL" or "AL, FS", and these were returning NONALUMNI, because of no wild card. I tried putting *AL*, but am still getting the NONALUMNI result. Any suggestions?

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if non appears in your string this might work:

    IIf(([CONSOURCES] like "*AL*" Or [CONSOURCES] like "*ALS*" Or [CONSOURCES]="*ALN*")) AND ([CONSOURCES] not like *NON*),"ALUMNI","NONALUMNI")

  6. #6
    bryenton is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    2

    Thank You very much!

    Thanks rpeare, that worked!

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

Similar Threads

  1. need a If /then statement
    By kmiszczak in forum Access
    Replies: 1
    Last Post: 04-12-2011, 01:51 PM
  2. replace a character with a wildcard
    By neeedhelp in forum Programming
    Replies: 2
    Last Post: 04-11-2011, 05:02 PM
  3. SQL wildcard character excluding
    By sandlucky in forum Access
    Replies: 2
    Last Post: 03-28-2011, 03:33 AM
  4. Wildcard Expressions in Search Field
    By eww in forum Programming
    Replies: 4
    Last Post: 09-29-2010, 10:27 AM
  5. Parameter Query & Wildcard
    By Rick West in forum Queries
    Replies: 8
    Last Post: 12-29-2009, 10:54 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