Nested IIf and IsNull

J

jim

I can't seem to get to syntax right on this query field. The nesting goes
this way:
find City Name by: if JobAddress4 and JobAddress3 is blank then get leftmost
characters of JobAddress2(always populated) up to ",", if JobAddress3 not
null get leftmost characters of JobAddress3 up to ",", and if JobAddress4 not
null get leftmost characters up to ",".

City:IIf(IsNull([tblClientBuildings].[JobAddress4]),IIf(IsNull([tblClientBuildings].[JobAddress3]),Left(([tblClientBuildings].[JobAddress2]),Inst([tblClientBuildings].[JobAddress2]),
",",-1),Left(([tblClientBuildings].[JobAddress3]),Inst([tblClientBuildings].[JobAddress3]),
",",-1),Left(([tblClientBuildings].[JobAddress4]),Inst([tblClientBuildings].[JobAddress4]), ",",-1)))
I get message function I've entered has wrong number of arguments. Any ideas?
TIA
 
R

RonaldoOneNil

Not tested but try this

City:IIf(Not
IsNull([tblClientBuildings].[JobAddress4]),Left([tblClientBuildings].[JobAddress4],Instr([tblClientBuildings].[JobAddress4],
",",-1)),IIf(Not
IsNull([tblClientBuildings].[JobAddress3]),Left([tblClientBuildings].[JobAddress3],Instr([tblClientBuildings].[JobAddress3],
",",-1)),Left([tblClientBuildings].[JobAddress2],Instr([tblClientBuildings].[JobAddress2], ",",-1))))
 

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

Similar Threads

IIf Len Question 2
Issue with IIF[fieldname] is not null statement 12
IIF IsNull help 6
IIF(IsNull) 3
Using ISNULL() 17
Joining IIF statements together 2
Help with IIF ans IsNull! 1
Using an iif 1

Top