That is what you would need to do to look at each record to determine if it is still a member of the current ID etc. There are multiple ways to go at it from there, and I am going to leave things for someone that is a much better developer than am I, but I wanted to get you something.
If you want to do some further searching in the Design Blog area, use this URL:
There are hundreds of mostly how-to posts in this area by our experts, so you should find some useful stuff there to give you ideas on on how to approach things. Sorry I do not have anything better for you.
To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question. I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.