Theoretically it can be done, but we would need to know the exact design of your Table. And, depending on the design, there might need to be pretty strict restrictions on how and when users can enter data.
For example, assuming you have the following design:
Projects Table
- ID - Autonumber, Long Integer, Primary Key.
- KSC_No - Text, 8 characters.
- From_Project - Number, Integer.
- To_Project - Number, Integer.
- Date_Of_Trans - Date/Time. Short Date.
- Is_Start_Date - Yes/No.
As long as all matching date pairs follow the rules below, you can do it:
- Both Records must have the same KSC_No.
- The From_Project of the first Record must match the To_Project of the other Record
- The To_Project of the first Record must match the From_Project of the other Record
- The second Record (the end date) must be entered BEFORE a new start date is entered unless the new start date has a different KSC_No, From_Project, or To_Project.
- The first record (the start date) must have Is_Start_Date checked.
- The second record (the end date) must NOT have Is_Start_Date checked.
As long as all of those rules are obeyed, the following Query can be used:
Code:
SELECT
A.ID,
A.KSC_No,
A.From_Project,
A.To_Project,
A.Date_Of_Trans AS Date_Start,
Nz((
SELECT
Min(C.Date_Of_Trans)
FROM
Projects AS C
WHERE
C.ID > A.ID AND
C.KSC_No = A.KSC_No AND
C.From_Project = A.To_Project AND
C.Is_Start_Date=False
GROUP BY
C.Date_Of_Trans
ORDER BY
C.Date_Of_Trans
),Date()) AS Date_End
FROM
Projects AS A
WHERE
A.Is_Start_Date=True
I've included a DB with an example.