Hi All,
I'm having trouble with [what I think is] some complex filtering for a subform I have.
I have a Many-to-many relationship between a Person and a Position, with a 'Join' table between the two. Within the Join table, I have the Person_ID, Position_ID, and Status among other things. Since there can be multiple entries for each Person and each Position, the status field is used when to prevent duplicate records from appearing in my subform for my user. For example, if a position has had 4 different people in it over its lifetime, there would be 4 different records appearing in my subform, when really there should just be one. The Status field has potential values of: Current, Past, or Future.
Currently I have the following filter:
This Filter prevents any People/Position that are 'Past' or 'Future' from being in the database, while also allowing null values to populate the subform because a position does not always have a person currently employing it.Code:strFilter2 = strFilter2 & "([Status] Is Null or [Status] = 'Current') AND "
That is what leads me to my problem, when a position is empty and has previously been occupied, there is no Current record, and the status is not null since there is already already a matching Position_ID with a status value. Therefore the subform does not show a record for this position even though my user would like it to.
Desired Output: Instead, I would like to change the filter to show all positions where status = null or current, but if neither are present, to show the most recent 'Past' record. My current filter listed above works this way in a sense, so long as it is a newly added position and there has never been somebody occupying it yet.
My thought process leads me to think I would need to loop through the records in the table to figure out which ones have no 'Current' status, that also have 'Past' records already in the Join table... Not sure how to do this however, and don't know if its feasible.
I hope I explained this sufficiently, if any of you have any advice on how to handle this, it would be greatly appreciated!
Thank you!
Skid