Basic Question- "IIF/Like"

  • Thread starter TA Bran via AccessMonster.com
  • 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
 
G

Guest

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

Guest

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
 
R

Rick B

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.
 
G

Guest

I messed up again

Try that
like IIf([Forms]![Search Contacts-Menu]![Name]="ALL","*",
[Forms]![SearchContacts-Menu]![Name])
 
T

TA Bran via AccessMonster.com

Thanks Rick and Ofer! I guess the problem was with my IIf stmt! It's
working like a champ now!

:^)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top