I have a problem with one of my databases that I have had for some time that is somewhat of an annoyance.
I have a form in continuous view in which the user must fill out some information for each record and then click a “commit” button (for each record).
Based on the values entered for that record, the “commit” button will first insert the information in one of two tables, then delete the record from the temporary table from which the form is querying.
psuedocode for it is here:
IF x.checked && y > 70 then
db.execute "Insert into tblCompleted values (me.empID,'completed',me.y);
else
db.execute "insert into tblIncompleted values (me.empid, 'incomplete', 'me.y);
end if
db.execute "delete * from tblTemporary WHERE empid = me.empID"
'form.requery
'form.refresh
I will sometimes get a ‘record is deleted’ runtime error, sometimes twice for the same record. However, all operations do work. After it has been completed, however, the record shows ##DELETED. To fix this, I put a Form.refresh and Form.requery statement at the end of my code. This will eliminate the ##DELETED record, but often throw me a “record is deleted” error.
Before you say “why are you using two tables, couldn’t this just be modeled with one table”, this is a simplified version of what I’m actually doing, and to me, using two tables makes more sense design-wise.
My main concern is this run time error. I could just catch it and leave it unhandled, but I’d prefer actually fixing it and sorting out this buggy form. Any thoughts?
I think the reason is that immediately after deleting the record, your form is still trying to show it. The answer in a related post suggests moving the bookmark to the previous record before deleting the current one using code like this.