Message Box when changing selection.

frankbutcher

Registered User.
Local time
Today, 09:14
Joined
Aug 6, 2004
Messages
192
Hi all.

Say if have a list box with selections 1,2,3,4,5. I would like a message box to appear if the selction is changed from.

I do have a message box appear saying "Are you sure you want to change" with a yes or no, but it changes the selction anyway. I have tried the code on the before and after event.

Where am I going wrong? Can anyone help?

Many Thanks.

Frank.
 
Use the list box's Before Update event to ask the question -

Code:
If MsgBox("Are you sure you want to change this?", vbQuestion + vbYesNo, "Change requested") = vbNo Then
   Cancel = True
End If
 
I have tried this but cant get it to work it still changes the option
 
Sorry, I forgot a piece:
Code:
If MsgBox("Are you sure you want to change this?", vbQuestion + vbYesNo, "Change requested") = vbNo Then
   Cancel = True
   Me.YourListBoxName.Undo
End If

or you might use
Code:
If MsgBox("Are you sure you want to change this?", vbQuestion + vbYesNo, "Change requested") = vbNo Then
   Cancel = True
   Me.YourListBoxName = Me.YourListBoxName.OldValue
End If
 

Users who are viewing this thread

Back
Top Bottom