472,102 Members | 1,037 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,102 software developers and data experts.

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 1802
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.