View Full Version : Error 3167


virtaccess
06-15-2007, 01:44 AM
Hi,
I have this code, it works fine, by deleting the record. But after deleting, when I place the cursor elsewhere, it gives Record is deleted 3167 error. Please help

Record is deleted. (Error 3167)
You referred to a record that you deleted or that another user in a multiuser environment deleted. Move to another record, and then try the operation again.


Private Sub Check12_Click()
'Me![1619IDRequirementDocumentation] = [Forms]![f04RequirementDocument]![tb19IDRequirementDocumentation]
'Me![tb1609IDApplication] = Me![09IDApplication]
'Fix for defect 2: Ramanan Pathmaraj
If (Check12.Value = -1) Then
Dim strSQL As String
Me![1619IDRequirementDocumentation] = [Forms]![f04RequirementDocument]![tb19IDRequirementDocumentation]
Me![tb1609IDApplication] = Me![09IDApplication]
'strSQL = "INSERT INTO t16ImpactedApplication19x09 (1619IDRequirementDocumentation,1609IDApplication)" & _
" VALUES (" & [Forms]![f04RequirementDocument]![tb19IDRequirementDocumentation] & _
"," & Me![09IDApplication] & ");"
'MsgBox (strSQL)
'DoCmd.RunSQL strSQL

ElseIf (Check12.Value = 0) Then
'Dim strSQL As String
Dim conDatabase As ADODB.Connection
Dim numRecordsAffected As Long
Set conDatabase = CurrentProject.Connection
DoCmd.SetWarnings False
strSQL = "DELETE t16ImpactedApplication19x09.*" & _
"FROM t16ImpactedApplication19x09 " & _
"WHERE t16ImpactedApplication19x09.[1619IDRequirementDocumentation]=" & _
Me![tb19IDRequirementDocumentation].Value & _
" and t16ImpactedApplication19x09.[1609IDApplication]=" & _
tb1609IDApplication.Value & " ;"
'MsgBox strSQL
DoCmd.RunSQL strSQL
'conDatabase.Execute strSQL, numRecordsAffected, adExecuteNoRecords
conDatabase.Close
Set conDatabase = Nothing

End If
End Sub

neileg
06-15-2007, 02:56 AM
So you have a record on screen and you delete it. The form is now positioned on a record that doesn't exist. You need to do something with the form.You could move it to another record or you could close it.

Moniker
06-17-2007, 11:30 AM
This will clear it up for you:

Me.Requery
Me.Refresh

Add those two lines to the end of your code. If the "Me" keyword is not referring to your form at that time, then you'll need to call the form by it's name and do that.