Microsoft KB Archive/98225

= ACC: How to Open a Combo Box Automatically =

Article ID: 98225

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q98225



Moderate: Requires basic macro, coding, and interoperability skills.



SUMMARY
When you are entering a large amount of data and want to open a combo box, it is inconvenient to have to press additional keys or stop to use the pointer. This article presents a generic macro that opens a combo box when you set the focus on the control by pressing the TAB key.

In Microsoft Access 7.0 and 97, you can use the Dropdown method to force the list in the specified combo box to drop down. If the specified combo box control does not have the focus, an error occurs. Using this method is identical to pressing the F4 key when the control has the focus.



MORE INFORMATION
A macro with a single action, SendKeys, is shown below. You can use this macro for all combo boxes on your form:

  Create a macro called Open Combo Box, as follows:

     Action SendKeys

Actions Arguments --     Keystrokes: %{DOWN} Wait: Yes  Open your form in Design view. Add the Open Combo Box macro to the OnEnter property of your combo box. Open your form in Form view, and use the TAB key to move to your combo box.

Using the Dropdown Method in Microsoft Access 7.0 and 97
 Create a new form.</li> Add a combo box and a text box control to the form.</li>  Set the combo box's OnGotFocus property to the following event procedure:

<pre class="fixed_text">     Private Sub Employees_GotFocus Me!ComboBoxName.Dropdown End Sub </li> Open your form in Form view, and use the TAB key to move to your combo box.</li></ol>

<div class="references_section">