#Error with simple IIF Statement in MS-Access

tomisin

New Member
Joined
Mar 16, 2011
Messages
2
I am currently trying to write a simple function in MS-Access 2003 using IIF and a few other functions (LEN and LEFT). However, I get the #Error in the required fields. Please, find below the function I wrote. I will greatly appreciate your assistance -

Unique_ID: IIf(Len([Airline Activity - Detail - Jan]![Middlename_IA]=1),Left([Airline Activity - Detail - Jan]![Firstname_IA],2) & [Airline Activity - Detail - Jan]![Lastname_IA],Left([Airline Activity - Detail - Jan]![Firstname_IA],2) & [Airline Activity - Detail - Jan]![Middlename_IA])
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Welcome to the Board!

Looks like you have the right parend on your LEN function in the wrong place. It should be before the equal sign, not after, i.e.:

Unique_ID: IIf(Len([Airline Activity - Detail - Jan]![Middlename_IA])=1,Left([Airline Activity - Detail - Jan]![Firstname_IA],2) & [Airline Activity - Detail - Jan]![Lastname_IA],Left([Airline Activity - Detail - Jan]![Firstname_IA],2) & [Airline Activity - Detail - Jan]![Middlename_IA])
 
Upvote 0
You may also want to check your fields for nulls which may also be causing issues. The handy Nz() function works well for this. Something like

Unique_ID: IIf(Len(Nz([Airline Activity - Detail - Jan]![Middlename_IA],""))=1, ...

hth,

Rich
 
Upvote 0
Thank you all. Your comments have been very useful. I will also check for Nulls because the data field definitely has some nulls
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top