I used this function as an interview question to review some bad code.
The bug in this code is not closing the recordset - but there are some other things that are not good here:
- (repeated) DB queries in a loop
- no error checking
- mixes display logic and business logic
- does not clear group caches
- it makes baby kittens sad