469,903 Members | 2,193 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Cancel Delete Doesn't Work

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?

Jul 18 '07 #1
1 1724
Baz
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

"Swinky" <sw********@lunt.comwrote in message
news:11*********************@x35g2000prf.googlegro ups.com...
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?

Jul 18 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by ryanmhuc | last post: by
reply views Thread by Rachel Suddeth | last post: by
reply views Thread by David C | last post: by
4 posts views Thread by Swinky | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.