Data has changed error

ijit

Registered User.
Local time
Today, 13:04
Joined
Oct 17, 2007
Messages
15
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:
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?
 
Setting Response = acDataErrContinue serves no purpose in this code. Could you post the RowSource for the ListBox? How does the ItemKey control get the value you need to do the delete?
 
I think, you should requery the form after deleting record.

olcaym
 
Requerying the form wroked perfectly. I also took out the Response = acDataErrContinue, thanks for the tip.
 

Users who are viewing this thread

Back
Top Bottom