Wow, give me a little bit more time to look through it, but preliminarily:
You seem to have the basic logic down, it appears to be your implementation that is causing you problems.
For starters, you should really try to use delete queries and select queries rather than cmdRecordDelete. Search...