|
|
cancel a combobox change
Hello. I want to be able to cancel a combobox change. Cancel is not
parameter in the change event, and there is not a beforechange event. I have
pasted my attempt below. No matter what item is selected in the event for
the combobox, it always changes back to whatever the user selected at the
conclusion of the event. Is there a work around that would effectivly be the
same as canceling the change?
Private Sub ComboBox1_Change()
Dim RUSure As Integer, GoBack As Integer
GoBack = ComboBox1.ListIndex 'set the goback value in case user wants to
cancel.
If SavedList = False Then
RUSure = MsgBox("Do you want discard changes to the list?", vbYesNo)
If RUSure = vbYes Then
SavedList = True
Else
ComboBox1.ListIndex = GoBack 'This line is my attempt to change it
back.
Exit Sub
End If
End If
ListBox2.Clear
If ComboBox1.ListIndex > -1 Then
For Each v In ThisWorkbook.Worksheets("SkillsDetails").Range("A:A")
If v = Empty Then Exit For
If v = ComboBox1.Text Then
ListBox2.AddItem v.Offset(0, 1).Value
End If
Next v
End If
End Sub
--
Thanks,
Mike
|
|
0
|
|
|
|
Reply
|
Utf
|
4/7/2010 6:00:02 PM |
|
It could be done with a simple loop that prevents any action being taken as
a result of the change unless the message box response equals vbYes,
RETRY:
'Code that calls the UserForm for the combobox
Private Sub ComboBox1_Change()
Ans = MsgBox("Are you sure the selection/entry is correct", _
vbYesNo, "VALIDATE")
If Ans = vbNo Then
GoTo RETRY:
End If
'Continue code execution
End Sub
"Mike Archer" <MikeArcher@discussions.microsoft.com> wrote in message
news:5F7207B9-3DEB-4384-8CE4-E9AB3A5D68B4@microsoft.com...
> Hello. I want to be able to cancel a combobox change. Cancel is not
> parameter in the change event, and there is not a beforechange event. I
> have
> pasted my attempt below. No matter what item is selected in the event for
> the combobox, it always changes back to whatever the user selected at the
> conclusion of the event. Is there a work around that would effectivly be
> the
> same as canceling the change?
>
> Private Sub ComboBox1_Change()
> Dim RUSure As Integer, GoBack As Integer
> GoBack = ComboBox1.ListIndex 'set the goback value in case user wants to
> cancel.
> If SavedList = False Then
> RUSure = MsgBox("Do you want discard changes to the list?", vbYesNo)
> If RUSure = vbYes Then
> SavedList = True
> Else
> ComboBox1.ListIndex = GoBack 'This line is my attempt to change it
> back.
> Exit Sub
> End If
> End If
> ListBox2.Clear
> If ComboBox1.ListIndex > -1 Then
> For Each v In ThisWorkbook.Worksheets("SkillsDetails").Range("A:A")
> If v = Empty Then Exit For
> If v = ComboBox1.Text Then
> ListBox2.AddItem v.Offset(0, 1).Value
> End If
> Next v
> End If
> End Sub
>
>
>
>
> --
> Thanks,
> Mike
|
|
0
|
|
|
|
Reply
|
JLGWhiz
|
4/7/2010 7:17:09 PM
|
|
|
1 Replies
650 Views
(page loaded in 0.036 seconds)
Similiar Articles: cancel a combobox change - microsoft.public.excel.programming ...Hello. I want to be able to cancel a combobox change. Cancel is not parameter in the change event, and there is not a beforechange event. I have ... DataGridView Add/Edit/Delete - microsoft.public.dotnet.languages ...This is a book Some book The user can then add, change or delete a row. ... Basic Language How can i add/display Combobox in Datagridview in Edit ... Undo a combo box selection - microsoft.public.access.formscoding ...Disable ENTER key in Combo Box - microsoft.public.access.forms ... If the ... Anything like e.Cancel for Combobox selection change? – iSid Apr 30 '10 at 14:31 Change edit Item box - microsoft.public.sharepoint.general ...cancel a combobox change - microsoft.public.excel.programming ... No matter what item is selected in ... being taken as a result of the change unless the message box ... ok , i'm making name tags for an event....have to change the ...cancel a combobox change - microsoft.public.excel.programming ..... is not parameter in the change event, and there is not a beforechange event. Userform List boxes - editing - then option to save changes (or no ...cancel a combobox change - microsoft.public.excel.programming ..... changes to the list ... userform - microsoft.public.excel.misc ... So change the name for the ... Looping UserForm ComboBox - microsoft.public.word.docmanagement ...cancel a combobox change - microsoft.public.excel.programming ... It could be done with a simple loop that prevents any action being ... the Cancel button on UserForm2 ... FrontPage Form Resultes with Excel - microsoft.public.excel ...Hi, I have a combo box in a form linked to a field ... cancel a combobox change - microsoft.public.excel ... unable to scroll the page - microsoft.public.frontpage ... incorrect null value in combobox - microsoft.public.access ...change the value of a combo box - microsoft.public.access ... > > What I am doing wrong? > > Thank you all ... How to prevent/cancel a combobox's value change in c# ... Disable ENTER key in Combo Box - microsoft.public.access.forms ...> > If the ComboBox is last in the TabOrder and you have the Form's Cycle ... Cancel is not parameter in the change event, and there ... GoBack = ComboBox1.ListIndex 'set the ... How to prevent/cancel a combobox's value change in c#? - Stack ...I have a combobox at the top of a form that loads editable data into fields below. If the user has made changes, but not saved, and tries to select a different option ... WPF ListView ComboBox Bound - Cancel changeOk, I have a ListView in a WPF Window that has a combobox column. The comboboxes have their items source bound to an Enumration, and the value bound to a ... Cancel a ComboBox SelectionChanged EventIs it possible to cancel a ComboBox SelectionChanged event? I don't want to change it, then change it back. I just want to cancel it in the c# code. (The ... ComboBox: Cancel SelectedIndexChanged event - Visual Basic .NETComboBox: Cancel SelectedIndexChanged event. Visual Basic .NET Forums on Bytes. .net - How can I handle ComboBox selected index changing? - Stack ...Anything like e.Cancel for Combobox selection change? – iSid Apr 30 '10 at 14:31 7/20/2012 3:30:04 PM
|
|
|
|
|
|
|
|
|