Microsoft KB Archive/181078

= ACC: Dropdown Method of Combo Box Not Working in Load Event of Form =

Article ID: 181078

Article Last Modified on 1/22/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q181078



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



SYMPTOMS
When you use the Dropdown method of a combo box in the Load event of a form, the combo box list does not automatically drop down when the form opens.



CAUSE
The form contains a subform that is displayed in Datasheet view.



RESOLUTION
Use one of the following methods to work around this problem.

Method 1
Invoke the Dropdown method of the combo box in the Open event instead of in the Load event.

Method 2
 Create a subform whose DefaultView property is set to Continuous Forms and whose ViewsAllowed property is set to Both. In Design view of the main form that contains the combo box, set the SourceObject property of the subform control to the form that you created in step 1. Create another form, which will serve as the subform that you want to display on the main form. Set its DefaultView and ViewsAllowed properties to Datasheet.  Set the OnLoad property of the form to the following event procedure:

Private Sub Form_Load

Me![ctlDropCombo].SetFocus Me![ctlDropCombo].Dropdown Me![ContinuousSub].SourceObject = "DatasheetSub"

End Sub 

This event procedure assumes that the name of your combo box is ctlDropCombo, the name of your subform control is ContinuousSub, and the name of the subform that you created in step 3 is DatasheetSub. Adjust the code to reflect the names of the combo box, the subform control, and the datasheet subform in your application.

Method 3
Use a subform whose DefaultView property is set to Continuous Forms.



STATUS
Microsoft has confirmed this to be a problem in Microsoft Access versions 7.0 and 97.

<div class="moreinformation_section">

MORE INFORMATION
Note that this behavior does not occur when you open the form in Form view directly from Design view.

Steps to Reproduce Problem
 Start Microsoft Access and open the sample database Northwind.mdb.</li> Create a new form that is not bound to any table or query.</li> Use the Subform/Subreport Wizard to add Customer Orders Subform 2 to the form.</li> Add a combo box called ctlDropCombo to the form. Set its properties as follows:

Name: ctlDropCombo Row Source Type: Value List Row Source: a;b;c</li>  Set the OnLoad property of the form to the following event procedure:

Private Sub Form_Load

Me![ctlDropCombo].SetFocus Me![ctlDropCombo].Dropdown

End Sub </li> Save the form as frmNoDrop and close it.</li> Open the form in Form view from the Database window. Note that the combo box list does not automatically drop down as expected.</li></ol>

<div class="references_section">