Hi All,
I use the following code on a command button to delete records on a subform (sbfrmProbeData1point1) from the parent form (frmIGICaseNumberData):
‘———————————————————————————————————
strMsg = “You will delete any data you have entered into the Probe Data Field!”
strTitle = “Do you want to delete this data?”
intAnswer = MsgBox(strMsg, vbExclamation + vbOKCancel, strTitle)
If intAnswer = vbOK Then
strSQLDelete = “DELETE * FROM qryProbeData1point1 ”
strSQLDelete = strSQLDelete & “WHERE LabDataPKID = ” & Me!lngLabDataPKID
DoCmd.SetWarnings False
DoCmd.RunSQL strSQLDelete
‘requery so it reflects the newly deleted records
Me.Requery
DoCmd.SetWarnings True
Else ‘other things which work fine
‘———————————————————————————————————-
At the Me.Requery line the code jumps to the OnCurrent of the subform (below), recalculating (updating) probability values. It is then, during the recalculation, when I get Error 3167, “Record is Deleted”. I’ve been able to dig out that this is a record locking thing because I am using the same query during both events. What I’ve read is mostly to just trap the error and resume next. I would much rather find out how to not have the error in the first place.
‘———————————————————————————————————-
Private Sub Form_Current() ‘on the subform in which the data is being deleted from
On Error GoTo HandleErr
If Me.NewRecord Then
Me!dblCummPI = “”
Me!dblCummRMNE = “”
Else
Me!dblCummPI = PIProbabilityProduct(“qryProbeData1point1”, [LabDataPKID]) ‘here is the line on which the error occurs
Me!dblCummRMNE = RMNEProbabilityProduct(“qryProbeData1point1”, [LabDataPKID])
End If
‘———————————————————————————————————–
A little background:
It’s a long story on why but I have two command buttons, 1 button pre-loads, as it were, a list of values into the subform, and then sets the subform to AllowAdditions = False. The other is the button described above. This happens when I *load* the data into the subform and then *unload* (delete) the records right after. If I change to another subform (there are 4 on the main form on tabs) and then change back and then delete the records, the query has been released and I can delete then with nary a grumble from Access. That is the reason I think it’s a Record Locking thing. But that is way too many button clicks for the people who will be using this and the subform full of #DELETES’s causes way too much concern. That is not an assumption on my part, I’ve been told.
How can I get around this? What other method(s) (if available) can I use to sidestep the locking (if that is really the cause) of the records?
If I must, then, well, I’ll trap it and go on.
Now, before I look like this guy Thank You.
gdr