Help with IIF in Query

lawsonium

Registered User.
Local time
Today, 03:52
Joined
Jul 6, 2006
Messages
40
Hi,

I am trying to write an IIF statement in the criteria of my query. I want to do something like this but can't get the syntax right. Can anyone help?

IIf([Forms]![Main Menu]![cboCountySelecter]="All Wales","Anglesey" Or "Blaenau Gwent" Or "Cardiff" Or etc etc...,[Forms]![Main Menu]![cboCountySelecter])

So basically I'm saying If the combobox says All Wales then include all the county names else just use what's in the combobox.
It errors saying the expression is to complex when I try to use the Or operator in the TRUE portion of the IIF.

Anyone?

Thanks in advance,

Matt.
 
You can put the criteria in a new column in the query grid like the following (replacing with the correct county field name):-

---------------------------------
Field: IIf([Forms]![Main Menu]![cboCountySelecter]="All Wales", True, [CountyFieldName] = [Forms]![Main Menu]![cboCountySelecter])

Show: uncheck

Criteria: True
---------------------------------

See this thread for explanation:-
http://www.access-programmers.co.uk/forums/showthread.php?t=103312
.
 
Hmmm. Not sure what you mean quite.

Just to get it straight, it might not be ALL the other counties all of the time, that's why I wanted to name them individually.

Does that change things?

Thanks,

Matt.
 
To list the counties, you can use the IN operator in the expression:-

------------------------
Field: IIf([Forms]![Main Menu]![cboCountySelecter]="All Wales", [yourFieldName] IN ("Anglesey","Blaenau Gwent","Cardiff","....","...."), [yourFieldName] = [Forms]![Main Menu]![cboCountySelecter])

Show: uncheck

Criteria: True
------------------------
.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom