• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

Cancelling button actions (1 Viewer)

Fiona

Member
Joined
Apr 28, 2003
Messages
135
Location
Sydney
Cancelling button actions in VB [solved]

Hey,

For my project I am doing a database kind of thing with VB (& Access)... and I have a button to delete records from the database. Anyway, how do I program it so that when you click on delete it gives you the option of cancelling, so you don't delete it, in case you press Delete by accident?

Thanks,

Fiona :)
 
Last edited:

Fosweb

I could be your Doctor...
Joined
Jun 20, 2003
Messages
594
Location
UNSW. Still.
Gender
Male
HSC
2003
What language you using?

Add a boolean variable, set to false.
Get confirmation of deleting user.
If the user wants to delete user, set boolean to True,
Then run the delete user code ONLY if the boolean is true...
Simple...
 
Last edited:

Fiona

Member
Joined
Apr 28, 2003
Messages
135
Location
Sydney
There is an option... Cancel... so I set that to true, and it didn't stop things from being deleted :)
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
Code:
    Dim retVal As Long
    retVal = MsgBox("really delete", vbOKCancel, "Delete?")
    
    If retVal = vbOK Then
      ' do delete
    end if
 

neester

Member
Joined
Feb 22, 2003
Messages
30
Location
South Sydney
Fiona
Even better would be (also i think its nicer coded):

Code:
If MsgBox("Are You Sure You Want To Delete?", "Delete Record", vbQuestion+VbYesNo) = vbYes then
'Do Delete
End If
You will get a message box, with YES NO options, and a QUESTION Mark Picture in the box :D

Hope It Helps You Out!
 

Fiona

Member
Joined
Apr 28, 2003
Messages
135
Location
Sydney
For some reason I couldn't get that one to work... Hmm... I'll fiddle around with it later, thanks :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top