By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,076 Members | 2,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,076 IT Pros & Developers. It's quick & easy.

Cannot cancel from delete

P: n/a
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.

Any suggestions for a fix?

Jul 18 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
JHB
Yes, read the answer "Bax" gave you in another thread you made, with nearly
the same subject.


"Swinky" <sw********@lunt.comskrev i en meddelelse
news:11**********************@z24g2000prh.googlegr oups.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.

Any suggestions for a fix?

Jul 18 '07 #2

P: n/a
You need to use the MsgBox as a function, detect the button pressed and act
accordingly:

If MsgBox("Confirm delete. Once you confirm, record will no longer exist.",
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**********************@z24g2000prh.googlegr oups.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.

Any suggestions for a fix?

Jul 18 '07 #3

P: n/a
On Wed, 18 Jul 2007 11:08:42 -0700, Swinky wrote:
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.

Any suggestions for a fix?
Read Dale Carnegie's "How to Make Friends and Influence People".

Posting the same question three times, each two hours apart, after it
has already been answered earlier, is NOT the way to make friends in
this, or any other, newsgroup.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jul 18 '07 #4

P: n/a
On Jul 18, 1:49 pm, "JHB" <w...@ofir.dkwrote:
Yes, read the answer "Bax" gave you in another thread you made, with nearly
the same subject.
Google was having problems with posts yesterday...sent my email twice
thinking I must have done something wrong. Turns out it was problems
on Googles end.

My problem is now solved. Thanks to all that responded!

Jul 19 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.