Cancel Delete Doesn't Work

Cancel Delete Doesn't Work

Post by Swink » Fri, 20 Jul 2007 01:37:12


I have added code to delete a record (and records in related tables)
in the OnClick property:

MsgBox "Confirm delete. Once you confirm, record will no longer
exist.", vbOKCancel
strSQL = "DELETE FROM TOrdAck WHERE OANo=" & Me!OANo
Set dbs = CurrentDb
dbs.Execute strSQL, dbFailOnError
MsgBox dbs.RecordsAffected & " record(s) deleted"

The delete works fine but when you click cancel from the msg box, the
record still gets deleted. I need to be able to cancel the delete
function to save the record.

What needs to be added/changed to my code?
 
 
 

Cancel Delete Doesn't Work

Post by Baz » Fri, 20 Jul 2007 01:42:44

If MsgBox ("Confirm delete. Once you confirm, record will no longerexist.",
vbOKCancel) = vbOK Then
strSQL = "DELETE FROM TOrdAck WHERE OANo=" & Me!OANo
Set dbs = CurrentDb
dbs.Execute strSQL, dbFailOnError
MsgBox dbs.RecordsAffected & " record(s) deleted"
End If