IIF Statement problem (1 Viewer)

ascaife

Registered User.
Local time
Tomorrow, 07:15
Joined
Nov 10, 2008
Messages
50
Can anyone tell me what I'm doing wrong with this statement:

Location: (IIf([ResidentialAddressCountry]=("") Or IsNull([ResidentialAddressCountry]),"A" & [HomePOCode],"X" & [ResidentialAddressCountry]))

It works if ResidentialAddressCountry is empty, but the else section doesn't work - just gives me #Error
 

MSAccessRookie

AWF VIP
Local time
Today, 17:15
Joined
May 2, 2008
Messages
3,428
Can anyone tell me what I'm doing wrong with this statement:

Location: (IIf([ResidentialAddressCountry]=("") Or IsNull([ResidentialAddressCountry]),"A" & [HomePOCode],"X" & [ResidentialAddressCountry]))

It works if ResidentialAddressCountry is empty, but the else section doesn't work - just gives me #Error

I believe that you have an extra set of () in the formula. Try the following instead:
(IIf([ResidentialAddressCountry]="" Or IsNull([ResidentialAddressCountry]),"A" & [HomePOCode],"X" & [ResidentialAddressCountry]))
(Note that the () has been removed)
 

khawar

AWF VIP
Local time
Tomorrow, 01:15
Joined
Oct 28, 2006
Messages
870
Or more simply

IIf(nz([ResidentialAddressCountry],"")="","A" & [HomePOCode],"X" & [ResidentialAddressCountry])
 
Last edited:

ascaife

Registered User.
Local time
Tomorrow, 07:15
Joined
Nov 10, 2008
Messages
50
Thanks guys. No luck on the first one but option 2 worked a treat - good to learn a new one there with nz too.

Much appreciated.

Cheers,

Andrew
 

Users who are viewing this thread

Top Bottom