Solved

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

Posted on 2008-06-20
3
261 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now