Access 2007 - Prompt and Error while deleting a record
Posted on 2007-10-13
I have a split database. I have a button on a form bound to table (tblCalls). The intent of this button is to delete the current record. I am using the following code in the OnClick event to do this deletion:
SQL = "DELETE * FROM tblCalls WHERE ID = " & Me.ID
This comes back with the following warning: "You are about to delete 1 row(s) from the specified table". This is correct, but I would like this question to not appear. How do you do this? In Access Options/Advanced I unchecked the Confirm/Document Deletions check box, but that didn't do anything.
If I answer Yes to the above question, I get the following error message "can't delete 0 record(s) in the delete query due to key violations and 1 record(s) due to lock violations.
Selecting Yes to this message is suppose to run the query. The record is not deleted. There are no other records associated with this parent record. I have set "Cascade Delete Related Records" to TRUE.
I have set "Record Locks" on the form to "Edited Record". The record was not edited. I tried moving to another record with the following code:
iCurrentID = Me.ID
' Move away from current record so it can be deleted
DoCmd.GoToRecord acDataTable, "tblCalls", acNext
' Delete Call - This record must exist
SQL = "DELETE * FROM tblCalls WHERE ID = " & iCurrentID
I get the error "GoToRecord isn't available now". What does this error message mean?
Thanks for your help