Basic Question- "IIF/Like"

  • Thread starter Thread starter TA Bran via AccessMonster.com
  • Start date Start date
T

TA Bran via AccessMonster.com

Hello all,

Pretty new to Access and running into this problem I hope you might be able
to help me with. I've created a Search Paramaters form that I'd like to
use so that users can enter values which are then passed on to a search
query. I've created a corresponding query that in the conditions field
lists the following statement:

IIf([Forms]![Search Contacts-Menu]![Name]="ALL",[Name],Like [Forms]![Search
Contacts-Menu]![Name])

If the search field Name remains with the default value "ALL" then the
query works correctly by returning all records but if the user types a
value (either complete or partial with wildcards) that should return some
records--no records come back.

I know I must be missing something totally obvious. Any suggestions would
be greatly appreciated.

Thanks,

TA
 
Try that
like IIf([Forms]![Search Contacts-Menu]![Name]="ALL","*", [Name],Like
[Forms]![SearchContacts-Menu]![Name])
 
Sorry for the prev one try that

Like IIf([Forms]![Search Contacts-Menu]![Name]="ALL",*,
[Forms]![SearchContacts-Menu]![Name])

If its All it will return all records else it will return what on the screen
 
another way is to allow them to leave it blank for all....

Like [Forms]![Search Contacts-Menu]![Name] & "*"


This will also allow them to enter a partial name and still get results.
 
I messed up again

Try that
like IIf([Forms]![Search Contacts-Menu]![Name]="ALL","*",
[Forms]![SearchContacts-Menu]![Name])
 
Thanks Rick and Ofer! I guess the problem was with my IIf stmt! It's
working like a champ now!

:^)
 
Back
Top