On Change VB Yes/No Question and Undo!

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

I have a combo box the looks up the contractor, name, address, phone, fax...
If the user changes the value of this i want a message box to popup and say
are you sure, change contractor?
Also if they say yes, then save, else if no then undo the change.
How can I do this?

Thank You So Much

Dave
 
Use the AfterUpdate event procedure of the combo to ask for confirmation:

Private Sub Contractor_AfterUpdate()
If MsgBox("Change?", vbYesNo+vbDefaultButton2) = vbNo Then
Me.Contractor.Undo
End If
End Sub
 
I have a combo box the looks up the contractor, name, address, phone, fax...
If the user changes the value of this i want a message box to popup and say
are you sure, change contractor?
Also if they say yes, then save, else if no then undo the change.
How can I do this?

Thank You So Much

Dave

I'd use the BeforeUpdate event (which can be cancelled):

Private Sub cboContractor_BeforeUpdate(Cancel as Integer)
Dim iAns As Integer
iAns = MsgBox("Are you SURE you want to change contractors?", vbYesNo)
Cancel = (iAns = vbNo)
End Sub

John W. Vinson[MVP]
 
Back
Top