IIf function

lmcc007

Registered User.
Local time
Today, 05:24
Joined
Nov 10, 2007
Messages
635
In my tblAddresses table I have a lookup field called TypeofAddress (Business, Delivery, Home, Mailing…)

I am trying to tell it to display only one type out of the bunch: TypeofAddress 1. If TypeofAddress is not equaled to 1 then display TypeofAddress 2 and so on.

I created a query using tblAddresses. The Criteria for TypeofAddress is:

IIf([TypeofAddressID]=1,[TypeofAddressID],[TypeofAddressID]=2 Xor
([Address].[TypeofAddressID])=3 Xor
([Address].[TypeofAddressID])=7 Xor
([Address].[TypeofAddressID])=8 Xor
([Address].[TypeofAddressID])=9 Xor
([Address].[TypeofAddressID])=10 Xor
([Address].[TypeofAddressID])=11 Xor
([Address].[TypeofAddressID])=12 Xor
([Address].[TypeofAddressID])=13 Xor
([Address].[TypeofAddressID])=14 Xor
([Address].[TypeofAddressID])=15 Xor
([Address].[TypeofAddressID])=16)​

I just discovered that it is not counting all my records.

Is there a better way to get this information?

Thanks!
 
My text book tells me If Then Else is not the best when you have many alternatives.

Try Select Case
 
Hi -

The more conventional way of doing this would be a separate
table (e.g. tblItemType) with two fields, AddressID & Address,
linked to your main table via AddressID.

Given the above, there'd be no need for either Iif() statements
or Xor processes.

Bob
 

Users who are viewing this thread

Back
Top Bottom