Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with SetFocus required please
I have a combobox in a userform and wish to prevent the leaving the value
blank. I have used the following code If ComboBox1.listIndex = -1 Then Msgbox "Please select a value" Combobox1.SetFocus End If It doesn't work - the focus moves to the next control Why is this ? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with SetFocus required please
I should have specified that I have used the code in the Exit Procedure as
follows Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If ComboBox1.listIndex = -1 Then Msgbox "Please select a value" ComboBox1.SetFocus End If End Sub Regards & TIA "Jim @Eclipse.co.uk" <JimBurton<NOSPAM wrote in message ... I have a combobox in a userform and wish to prevent the leaving the value blank. I have used the following code If ComboBox1.listIndex = -1 Then Msgbox "Please select a value" Combobox1.SetFocus End If It doesn't work - the focus moves to the next control Why is this ? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with SetFocus required please
Instead of ComboBox1.SetFocus, try using Cancel = True instead.
Rick "Jim @Eclipse.co.uk" <JimBurton<NOSPAM wrote in message ... I should have specified that I have used the code in the Exit Procedure as follows Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If ComboBox1.listIndex = -1 Then Msgbox "Please select a value" ComboBox1.SetFocus End If End Sub Regards & TIA "Jim @Eclipse.co.uk" <JimBurton<NOSPAM wrote in message ... I have a combobox in a userform and wish to prevent the leaving the value blank. I have used the following code If ComboBox1.listIndex = -1 Then Msgbox "Please select a value" Combobox1.SetFocus End If It doesn't work - the focus moves to the next control Why is this ? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with SetFocus required please
Thank you Rick - works just as I need
"Rick Rothstein (MVP - VB)" wrote in message ... Instead of ComboBox1.SetFocus, try using Cancel = True instead. Rick "Jim @Eclipse.co.uk" <JimBurton<NOSPAM wrote in message ... I should have specified that I have used the code in the Exit Procedure as follows Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If ComboBox1.listIndex = -1 Then Msgbox "Please select a value" ComboBox1.SetFocus End If End Sub Regards & TIA "Jim @Eclipse.co.uk" <JimBurton<NOSPAM wrote in message ... I have a combobox in a userform and wish to prevent the leaving the value blank. I have used the following code If ComboBox1.listIndex = -1 Then Msgbox "Please select a value" Combobox1.SetFocus End If It doesn't work - the focus moves to the next control Why is this ? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Setfocus Problem | Excel Programming | |||
SetFocus? | Excel Programming | |||
SetFocus problem | Excel Programming | |||
setfocus | Excel Programming | |||
setfocus after a msgbox | Excel Programming |