473,732 Members | 2,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.RecordsAffe cted & " 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 1950
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.RecordsAffe cted & " record(s) deleted"
End If

"Swinky" <sw********@lun t.comwrote in message
news:11******** *************@x 35g2000prf.goog legroups.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.RecordsAffe cted & " 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
18346
by: ryanmhuc | last post by:
I have a function which needs to cancel the input into a text field on a form. I cancel the event in IE fine and the text does not get entered. But for firefox (1.0) I cancel the event and the text still gets entered. I've stripped the function down just to try to get it to work in Firefox. The alert does happen on the keydown event so it should be cancellable. function formatInput(e){
6
1999
by: downwitch | last post by:
OK, the last time didn't get an answer, let's see if I can explain it better. (Someone else here _must_ have done this at some point?) I have a progress-meter type thing set up to follow the compacting of a database, using Michael Kaplan's COM add-in. The plug-in exposes an event as the the "pieces" are completed; this event includes a Cancel argument, identical in nature to forms' BeforeUpdate and BeforeDelConfirm events, etc.--set it...
0
2116
by: Rachel Suddeth | last post by:
I have a tabbed ap, and I want to provide a message and give the user a chance to change there mind if they try to change tab pages in the middle of an update (otherwise just cancel the update and allow the change.) I thought the TabPage.Validating event would be the thing, and as long as buttons and tab page changes are done by mouse clicks, it seems to work fine. But if I use a hot key to press "Cancel" or "Save", it seems to raise the...
21
9217
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on the cancel button, the textbox.validating is being called. I don't want it to be since they are exiting the screen the validation doesn't have to be done. How can I do that.
2
635
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I change the confirm box to say yes/no or default to cancel? ----------------------------------------------------------------------- The buttons on a confirm box cannot be changed, nor can you specify a default button. However, you should be able to change the question so that "OK" is suitable as the default. e.g. change "We will now buy ourselves...
1
2803
by: Richard | last post by:
A shipment of material is received. The shipment contains several items. Each item is assigned an internal tracking number for auditing purposes and further processed. The tracking number is mandatory, unique and non-zero, but _cannot_ be obtained or assigned automatically by Access (due to business rules ). Table A is the receive table Columns: AID, ReceiveDate, CompanyID
0
1421
by: David C | last post by:
I have a GridView with a Delete link and wondered where the best place was to check and cancel delete of a row/record that is bound to an SqlDatasource. I can use datasource Deleting event or GridView_RowDeleting event. I need to get 2 values from the row I am trying to delete so I can perform another function returns whether I can delete the record or not. I am trying to do this in gridview event (see code below) but it is not working....
4
2048
by: Swinky | last post by:
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"
0
2816
by: Eraser | last post by:
Hi to all .NET guru guys... I have a problem in my delete button inside gridview. How to avoid postback on when i select cancel on confirmation message? But postback is okay on Ok confirmation. What happened is if I select cancel on my confirmation button, it executes the griedview postback which i assigned in my code behind. Please see my codes below... Code beind: protected void gvDefectCatalog_RowDataBound(object sender,...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9307
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9235
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.