The gift that keeps on giving . . .
Hmmm. . . Nasty little critter isn't it.
Well, at this point I think it's worth re-considering the value and purpose of your <Delete> button.
From an auditing perspective, for anyone to be examining the integrity of your data and then seeing holes where the Autonumber fields aren't consecutive (because records are deleted) is usually an invitation for closer scrutiny by an auditor. This may not be any kind of concern in your situation (although I should think data pertaining to patients would be likely to fall within the realm of formal audits), but it's worth mentioning.
Secondly, your msgbox prompting the user to return the machine prior to deleting the record strikes me as more than a little schizophrenic (pardon the jest, but I only do so for the purpose of illustration). If the machine was legitimately on loan, then why is the record being deleted? If not, then how did an illegitimate TENSEpisode record get intentionally created (notwithstanding our dear 'ghost' records, of course)?
So, presuming the latter case, I suspect that much of the purpose of your delete button is merely as a means for the user to 'Cancel Out' from actually adding a TENSEpisode record they've begun to create.
Your solution to this would simply be (at least for starters) to set Cancel=True in the Form's BeforeUpdate event if user clicks the henceforth named <Cancel> button. Well, strike the 'simple' qualification - I can see this is gonna have to be thought through more clearly on my part . . .
You may still have some behind-the-scenes writing of values to tables through recordsets, which complicates the matter of Cancelling Out of a record add/update, but this should give you plenty to think about for now.
I'll be interested to hear of your findings or disclaimers, and whether or not my observations were on the mark.
Cheers!
John
PS - an executable command like Delete or Move, etc can't be run while the code module is the active window, which is why debugging won't take you past that line of code.