I have an Access database front-end and I'm trying to put a button on a form to delete the current record. I used the following VBA code to delete the record:
If Me.NewRecord Then
Me.Undo
Exit Sub
End If
DoCmd.RunCommand acCmdDeleteRecord
Me.Requery
Me.Refresh
When I run this on records that I inserted into the database with the form, It returns Run-time error '2501' on the DoCmd. However, if I run it on a record that had already existed in the database then the code completes as intended.
Additionally, no one else is accessing this database table yet and I only had the one form open.
When I went to delete them from the linked table manually in access I got the same error but I was able to delete them from the database using SQL Server Management Studio.
What would cause this to happen?
EDIT
I did some more investigating and found that I am unable to edit the new records in in the base table using access either. I get an error about the records being changed by another user.