Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RegEx help in C#.NET 8 55
pattern problem 9 79
Java / Linux and Regular Expressions 11 76
extracting data from a variable regular expression 2 23
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…
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…

815 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

9 Experts available now in Live!

Get 1:1 Help Now