?
Solved

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

Posted on 2008-06-20
3
Medium Priority
?
281 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
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…
Suggested Courses

765 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