I have a form with a list box in it. I also have a button that deletes a record out of the table depending on whatever is selected in the list box.
The issue I am having is when I return to the form after the code has run, and I choose another option in the list box, it says, "The data has changed. Another user edited this record..."
Here's the code:
I'm assuming it is happening because after the code has run, the listbox is still showing the active record as the one that was just deleted. How do I choose another record in the listbox, or what else can I do to make it so the form doesn't give that error?
The issue I am having is when I return to the form after the code has run, and I choose another option in the list box, it says, "The data has changed. Another user edited this record..."
Here's the code:
Code:
Private Sub Command132_Click()
On Error GoTo Err_Command132_Click
' Prompt user to verify they wish to delete record
strMsg = "Are you totally sure you want to do this?"
If MsgBox(strMsg, vbYesNo) = vbYes Then
CurrentDb.Execute "DELETE * FROM ItemList WHERE ([ItemKey]=" & Me.ItemKey & ")"
Me!List61.Requery
Else
Response = acDataErrContinue
End If
Exit_Command132_Click:
Exit Sub
Err_Command132_Click:
MsgBox Err.Number & ":" & Err.Description
Resume Exit_Command132_Click
End Sub
I'm assuming it is happening because after the code has run, the listbox is still showing the active record as the one that was just deleted. How do I choose another record in the listbox, or what else can I do to make it so the form doesn't give that error?