Create a query using your table.
Type an expression like this into a fresh column in the Field row:
NextPromoDate: (SELECT Min(PromoDate) AS MinOfPromoDate
FROM Table1 AS Dupe
WHERE (Dupe.EmpID = Table1.EmpID)
AND (Dupe.PromoDate Table1.PromoDate))
Replace "Table1" with the name of your table.
Once you have that working, you can use Nz() to supply today's date if
there's no future promotion, and use DateDiff() to get the difference:
TimeInGrade: DateDiff(d", [PromoDate],
Nz((SELECT Min(PromoDate) AS MinOfPromoDate
FROM Table1 AS Dupe
WHERE (Dupe.EmpID = Table1.EmpID)
AND (Dupe.PromoDate Table1.PromoDate)), Date()))
If subqueries are new, see:
How to Create and Use Subqueries
at:
http://support.microsoft.com/?id=209066
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
<ApexData@gmail.comwrote in message
news:1165863050.892202.119030@f1g2000cwa.googlegro ups.com...
Quote:
Hello
>
My MainForm manages Employee records. I have created another form that
manages employee promotions. On the MainForm a button launches the
PromotionForm and lists the promotions for the employee shown on the
MainForm. The buttons clickevent looks like this: DoCmd.OpenForm
stDocName, , , "EMPID = " & Me.txtEMPID
>
The results are FILTERED. The Form is Continuous.
Fields are: (EmpID) (Rank) (PromoDate) and UnboundTxtBox:
(TimeInGrade)
I have placed a UnBound TextBox in the PromotionsForm called
(TimeInGrade) and want to be able to display the amount of time the
employee held a rank before moving on to the next promotion. The Last
promotion to be calculated as (date() - LastPromo)
>
EXAMPLE:
>
RANK PromoDate TimeInGrade
FF 01/01/1990 365days
Lieut 01/01/1991 1460days
Capt 01/01/1995 4361days
>
How do I calc forward to the next field or iterate the filtered results
to get my solution?
>
Greg