databasedev.co.uk - database solutions and downloads for microsoft access

Microsoft Access Combo Box

Automatically display a Microsoft Access combobox list:

Using the GotFocus() event procedure

If space on a form is limited, a combobox is definitely more economical than a listbox. Still, you may want users to be able to see the contents of the combobox as soon as the control has focus. That way, they can quickly pick their choice and move on.

Fortunately, as with most things in Microsoft Access, you can manipulate just about anything with code. You can easily use VBA to automatically open the dropdown list as soon as a combobox has focus by using the control's Dropdown method. For instance, let's say that a form contains a combobox control named cboBookCategory. The following procedure, added to the GotFocus() event procedure of your combo box:

Private Sub cboBookCategory_GotFocus()
'When the combo box receives focus
'display in drop down position
    Me.cboBookCategory.Dropdown
End Sub

can be used to display a list of book categories when the combobox receives focus.

When you tab through to the control it will automatically display as follows:

Tabbing to the combo box will automatically invoke the combo to drop down.
Tabbing to the combo box will automatically invoke the combo to drop down.

Why not check out the following for much more information on using VBA in Microsoft Access: