delete record - message "The data has been changed."

billwagnon

New member
Local time
Today, 23:46
Joined
Jan 30, 2003
Messages
9
I put a delete button on my form to delete records from two tables - the "project" from the _Project table and the project items from the _ProjectItems table.

This appears to work, but when the user selects another project from the listbox this error comes up:

"The data has been changed.

Another user edited this record and saved the
changes before you attempted to save your changes.

Re-edit the record."


I could simply turn off the warnings, but I want to make sure I do this right!

Here's my delete code for the button:

Code:
[size=1]
Private Sub cmdDeleteProject_Click()

Dim iAns As Integer

    iAns = MsgBox("Delete project '" & _
ProjectName & "' " &  vbCrLf & "from " & _
Trim(DLookup("ccompany", "_ARCUST", "ccustno='" & cboCustomer & "'")) & "?" & vbCrLf & vbCrLf & _
            "This operation cannot be undone.", vbOKOnly, "appname")
    
    If iAns = vbOK Then
        DbDelete CurrentDb, "_Project", "Project=" & _
lsbProject
        DbDelete CurrentDb, "_ProjectItems", "Project=" & _
lsbProject
        cboCustomer.Requery 'get customer refill
        lsbProject.Requery 'get project refill
        'take focus off cmdDeleteProject
        lsbProject.SetFocus
        'hides subform and record input boxes 
        'until new record is selected
        Visibility False
    Else
        MsgBox "Delete operation cancelled.", vbInformation, "appname"
    End If


End Sub
[/SIZE]
 
Last edited:

Users who are viewing this thread

Back
Top Bottom