Problem with IIf in query

  • Thread starter Thread starter mac
  • Start date Start date
M

mac

Hi

Can someone tell me why the True part does not return any records but
the False part does in the following query:

Like
IIf([Forms]![SelectReports]![ExcludePLT].[Value]=True,([Forms]![SelectReports]![DocTypeCombo]
& "*" And <>".plt"),[Forms]![SelectReports]![DocTypeCombo] & "*")

It is definitely a syntax error because if I run the 2 parts queries
separately they both return the records I am after.

This works:
Like [Forms]![SelectReports]![DocTypeCombo] & "*" And <>".plt"

So does this:
Like [Forms]![SelectReports]![DocTypeCombo] & "*"

Thanks in advance

Mark
 
You can't place the "And <>"." inside the IIf(). You can use two IIf()s with
the same condition argument and place the "And <>" between them.
 
Hi Duane

Thanks for the reply!

I have used this:

Like [Forms]![SelectReports]![DocTypeCombo] & "*" And
<>IIf([Forms]![SelectReports]![ExcludePLT]=True,".plt","*")

I wasn't sure what to put in the False part of the IIf

And <>"*" Seems to work, is that correct ?

Thanks again

Mark
 
Test a bunch of different values in your controls to make sure it works as
expected.
 

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

Back
Top