cancel with message box

megatronixs

Registered User.
Local time
Today, 20:42
Joined
Aug 17, 2012
Messages
719
Hi all,

I have the below code that when a user will make a change in a combo box, it will pop up a message asking if they want to do so (to make them aware of it). How could I change it so there is a extra button cancel and when they hit cancel, the combo box will keep the value, if OK is hit, then make the change.

Code:
 If Me.Business = "TYPE 1"  And Me.Case = "Sent Email" Then
 MsgBox ("You really want to change this!!!")
End If

Greetings.
 
if MsgBox ("You really want to change this!!!",vbyesnocancel,"EMAIL CHANGE") <>vbyes then
'cancel operation
end if
 
Try BeforeUpdate event.
Code:
Private Sub Business_BeforeUpdate(Cancel As Integer)
    If Me.Business = "TYPE 1"  And Me.Case = "Sent Email" Then
        If MsgBox ("You really want to change this!!!", vbYesNo) = vbNo Then
            Cancel = True
        End If
    End If
End If
 
Hi all,

I tried the one from pr2-eugin, when I hit cancel, it will still change the value :-(

Any way I did it wrong?

Greetings.
 
Code:
        If MsgBox("Do you really want to change the value?", vbYesNo + vbQuestion + vbDefaultButton2) = vbNo Then
            Cancel = True
            Me.cmbRemote_ID.Undo
        End If


This should work.
 

Users who are viewing this thread

Back
Top Bottom