Nested IIf in Query

wilson51

Board Regular
Joined
Mar 31, 2003
Messages
50
My table includes 6 date fields (First, Second Third etc) which are used to trace advertised dates.

I need to be able to identify the latest advertised date from First, Second, Third etc and update that to a field LastDate

IIf([Openhouse]![two]>[Openhouse]![one],[Openhouse]![two],IIf([Openhouse]![three]>[Openhouse]![two],[Openhouse]![three],IIf([Openhouse]![four]>[Openhouse]![three],[Openhouse]![four],IIf([Openhouse]![five]>[Openhouse]![four],[Openhouse]![five],IIf([Openhouse]![six]>[Openhouse]![five],[Openhouse]![six],0)))))

Why won't it work?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I hate to say it, but it sounds like you may have a design issue. It sounds like your tables may not be in First Normal Form (which says that the tables do should not contain repeating groups of fields).

Instead of having a table in which you have fields that says "1st instance", "2nd instance", etc, you should redesign it so that you have a table that has "instance number" as a field and "date of instance" as a field. So instead of having a row of data with six dates, you will have six row of data with one date.

Then, you can group the data in a query by the identifying field and use the MAX funxtion to return the most current date.
 
Upvote 0
jmiskey said:
I hate to say it, but it sounds like you may have a design issue. It sounds like your tables may not be in First Normal Form (which says that the tables do should not contain repeating groups of fields).

Instead of having a table in which you have fields that says "1st instance", "2nd instance", etc, you should redesign it so that you have a table that has "instance number" as a field and "date of instance" as a field. So instead of having a row of data with six dates, you will have six row of data with one date.

Then, you can group the data in a query by the identifying field and use the MAX funxtion to return the most current date.
Thanks for your help
 
Upvote 0

Forum statistics

Threads
1,221,687
Messages
6,161,287
Members
451,695
Latest member
Doug Mize 1024

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