Essentially I have a table of data where actions occur on certain dates. There is a separate table with ranges that these dates fit in. a date start and date end. I want to show next to the information of these people, the starting date where their action fits in and the highest ending date where their action fits in, but the issue is this: The highest ending date can't be greater than the next effective date assuming the next person is the same name. Now if both dates share a common max end date then it can show the same date.
I'm having trouble in terms of writing something such as this. I've already found an easy solution for the starting date, but not the end. I attached an example database with two tables of data and a third called result which is essentially what I'm trying to see in the end. If anyone has any ideas, it would really help!
Example.zip
Hope I explained it well enough, but let me know if there are any questions.
edit: Next name and name column may have gotten switched when i wrote the results table.
edit2: My attempt at a solution was placing this iif statement in the criteria, but of course that would exclude records.
Code:
IIf([next name]=[name],IIf([Next Date]>=[effective date]+14,[end]<=[next date] And [end]>=[effective date],[end]>=[effective date]),[end])
Attempting to place it within the max() itself just results in 12:00:00 in the record rather than getting the outcome I'm looking for in result