ComboBox .Undropdown Method

Combo boxes in Access have a .Dropdown method. Several years ago, I asked if there was some way to perform the opposite action.  Essentially, I wanted a .CloseDropdown method or a .UnDropdown method.  Here was my question on stackoverflow:

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.

Adam Waller of Access Version Control fame came to the rescue with his answer:

I was dealing with 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.

In other words, setting the combo box's ListWidth property to itself is a reliable way to force a combo box's dropdown list to close.


External references

Opposite of combo box .Dropdown method?
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 = TrueM...
User AdamsTips
Stack Overflow | The World’s Largest Online Community for Developers

Referenced articles

A Quick, Free Way to Try Version Control with Microsoft Access
Curious about getting started with version control in Microsoft Access, but don’t want to commit a lot of time or money? This could be just the solution for you.

Image by suju-foto from Pixabay