Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opposite of combo box .Dropdown method?

Tags:

ms-access

Is there a way to toggle the dropdown of a combo box through VBA? .Dropdown is a method and it only works in one direction. I'm looking for the following functionality:

MyCombo.Dropdown = True
MyCombo.Dropdown = False

Obviously the above does not work in MS Access. I'm guessing I'll need to use some sort of hack/workaround for this. I'd like to avoid a .Requery. That would probably work, but there could be a major performance penalty depending on what the source of the combo box is.

like image 331
mwolfe02 Avatar asked Jan 12 '12 18:01

mwolfe02


People also ask

What is the difference between a combo box and a drop-down list?

A drop-down list is a list in which the selected item is always visible, and the others are visible on demand by clicking a drop-down button. A combo box is a combination of a standard list box or a drop-down list and an editable text box, thus allowing users to enter a value that isn't in the list.

What is the function of combo box?

A ComboBox displays a text box combined with a ListBox, which enables the user to select items from the list or enter a new value. The DropDownStyle property specifies whether the list is always displayed or whether the list is displayed in a drop-down.

What is a combo box in VBA?

Combo Box is the UserForm feature in VBA. They are different from the text boxes as text boxes used to contain only text. We allow the user to input any data, but by using combo boxes, we limit users to the desired response type. Thus, the data is in an orderly fashion.


1 Answers

I was dealing this this issue today, and after a lot of trial and error, I discovered that the following works beautifully in Access 2010:

With m_cboLookup
    .ListWidth = .ListWidth    ' Close combo box
    'If Len(strSearch) > 3 Then .Dropdown
End With

Essentially, you are just setting the list width to the existing list width, but the combo box is closed, presumably to prepare for redrawing at a different size.

like image 125
AdamsTips Avatar answered Oct 18 '22 07:10

AdamsTips