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

ID: Q181078


The information in this article applies to:


SYMPTOMS

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

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


  1. Create a subform whose DefaultView property is set to Continuous Forms and whose ViewsAllowed property is set to Both.


  2. 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.


  3. 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.


  4. 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.


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


  1. Start Microsoft Access and open the sample database Northwind.mdb.


  2. Create a new form that is not bound to any table or query.


  3. Use the Subform/Subreport Wizard to add Customer Orders Subform 2 to the form.


  4. 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


  5. Set the OnLoad property of the form to the following event procedure:
    
          Private Sub Form_Load()
    
             Me![ctlDropCombo].SetFocus
             Me![ctlDropCombo].Dropdown
    
          End Sub 


  6. Save the form as frmNoDrop and close it.


  7. Open the form in Form view from the Database window. Note that the combo box list does not automatically drop down as expected.



REFERENCES

For more information, search the Help Index for "Dropdown method."

Additional query words: pra expand


Keywords          : FmsEvnt FmsCmbo 
Version           : WINDOWS:7.0,97
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: April 27, 1999