ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   DropDown rephrased (https://www.excelbanter.com/excel-programming/336924-dropdown-rephrased.html)

Geoff

DropDown rephrased
 
Hi
I would like to prevent the list showing in a combobox if a condition is not
met in another control elsewhere on a userform.

It is not possible to use the other control's Exit event and Cancel = True
and I cannot disable or lock the combobox as it's DropButtonClick event would
not be fired.

If
ComboBox1.DropDown can reveal the list then:
ComboBox1.DropDown = False has no effect.

What should the syntax be to prevent DropDown? Appreciate any ideas.


T.I.A.

Geoff

Toppers

DropDown rephrased
 
Geoff,
Perhaps disable the Combobox (Enabled=False) while your
condition exists?

"Geoff" wrote:

Hi
I would like to prevent the list showing in a combobox if a condition is not
met in another control elsewhere on a userform.

It is not possible to use the other control's Exit event and Cancel = True
and I cannot disable or lock the combobox as it's DropButtonClick event would
not be fired.

If
ComboBox1.DropDown can reveal the list then:
ComboBox1.DropDown = False has no effect.

What should the syntax be to prevent DropDown? Appreciate any ideas.


T.I.A.

Geoff


Geoff

DropDown rephrased
 
Hi Toppers
Thanks for the reply, I have found a way. Right or wrong it seems to work.

In further testing I found that if I returned the focus to the 'conditional
' control from the cbobox in an cbobox_enter event like so, it prevents the
list showing.

Private Sub cbo1_Enter()

If opt1.Value = False And opt2.Value = False Then
fraop1opt2.SetFocus
Exit Sub
End If
'rest of code

End Sub

Geoff

"Toppers" wrote:

Geoff,
Perhaps disable the Combobox (Enabled=False) while your
condition exists?

"Geoff" wrote:

Hi
I would like to prevent the list showing in a combobox if a condition is not
met in another control elsewhere on a userform.

It is not possible to use the other control's Exit event and Cancel = True
and I cannot disable or lock the combobox as it's DropButtonClick event would
not be fired.

If
ComboBox1.DropDown can reveal the list then:
ComboBox1.DropDown = False has no effect.

What should the syntax be to prevent DropDown? Appreciate any ideas.


T.I.A.

Geoff



All times are GMT +1. The time now is 03:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com