Solved

Delete Record Confirmation - How do I prevent a deletion if user changes his mind?

Posted on 2008-06-20
3
268 Views
Last Modified: 2008-09-01
I am working with a details view form and have added some code to warn the user they have clicked on the Delete Button. However, if they realise they do not want to delete the record and click on the "No, (don't let me do it)" button, it stills deleted the record. How do I make my "No" button work?
I am working with Visual Basic, with a SQL database.
'This is what I have...
 Private Sub BindingNavigatorDeleteItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem1.Click
        Dim result As New DialogResult
 
        result = MessageBox.Show("Confirm Delete", "Delete Database", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
 
        If result = DialogResult.Yes Then
            MessageBox.Show("Deletion Successful")
        End If
    End Sub

Open in new window

0
Comment
Question by:teustace
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Expert Comment

by:60MXG
ID: 21850474
Private Sub BindingNavigatorDeleteItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem1.Click
        Dim result As New DialogResult
 
        result = MessageBox.Show("Confirm Delete", "Delete Database", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
 
        If result = DialogResult.No Then
            MessageBox.Show("Are you sure to cancel the delete action?")
            -- Exit or redirect to previous screen code here
        ELSE if
           -- Do the delete action code here
        End If
    End Sub

I hope this help!
0
 

Accepted Solution

by:
teustace earned 0 total points
ID: 21879740
Hi 60MXG, many thanks for your response. Sorry for my late reply.

I actaully have the code you have kindly given me but not the bits you have suggested I use after the message. (I'm pretty dumb on coding). What do you mean "Do the delete action"? Doesn't the Binding Navigator take care of that? Anyway, I am more interested in preventing a delete if user changes their mind. So, what happens after they select the "No" MessageBox warning?
0
 
LVL 7

Expert Comment

by:60MXG
ID: 21911687
-- Do the delete action code here
meant you can code whatever you want such as delete something or disable or redirect user to begining of the form etc.  
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question