Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Fixing some Issues with regex again 9 27
Help with regular expressions query 39 68
RegEx help in C#.NET 8 51
Regular expression that only finds last instance 1 56
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…
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…
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…

910 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

16 Experts available now in Live!

Get 1:1 Help Now