Combo box .DropDown not staying dropped down

Will_B

Board Regular
Joined
Mar 4, 2009
Messages
79
Hi. I want a combo box to automatically drop down when it has the focus, including when I use the .SetFocus method on it when the form opens. The problem is that the combo box only opens for a split second (I see the values listed for only a moment), but the combo box closes rather than stays open.

To try to diagnose the problem, I created a form that only contains a combo box (cmbTEST) and only the event code below. The problem occurs even with this simple situation.

Code:
Private Sub Form_Open(Cancel As Integer)
  Me!cmbTEST.SetFocus
End Sub
 
Private Sub cmbTEST_GotFocus()
  Me!cmbTEST.Dropdown
End Sub

I am using Access 2007 and have the following references set in the VBA editor.

* Visual Basic For Applications
* Microsoft Access 12.0 Object Library
* OLE Automation
* Microsoft 12.0 Access database engine Object Library

Thanks for any assistance.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Why not use a listbox instead?

That should permanently be displayed and could be sized to suit.
 
Upvote 0
Expanded list boxes would take up a lot of space with the number of options I need to include. An automatically dropped-down combo box prompts the user to select necessary criteria, but collapses after that is done.
 
Upvote 0
Will

What are you doing with the combobox?

Are you allowing the user to make multiple selections from it?
 
Upvote 0
Possibly the Open event is too soon on the order of form events. Try the activate event. And be sure the drop down is the first tab stop.

http://office.microsoft.com/en-ca/access-help/order-of-events-for-database-objects-HP005186761.aspx
Events occur for forms when you open or close a form, move between forms, or work with data on a form.

Opening and closing a form

When you open a form, the following sequence of events occurs for the form:

Open → Load → Resize → Activate → Current

If there are no active controls on the form, the GotFocus event also occurs for the form after the Activate event but before the Current event.
 
Upvote 0
Thanks for responding, Xenou. The combo box is the only control on the form, so it is the only tab stop (and the "Tab stop" property is set to "Yes"). After the form is opened, the cursor is inside the combo box, so tab-stopping doesn't appear to be the problem.

I should have mentioned in my previous post that I had tried the code in the form's OnOpen, OnActivate, OnCurrent, and GotFocus events, all with the same results: brief opening of the combo box, then it's closed. I tried it again just now to be sure and got the same flickering results. Thanks for mentioning that possibility.

Just now I tried putting the following code into a command button and it DID perform the DropDown successfully --- so references don't appear to be the problem, only how to implement DropDown when the form is first opened:

Code:
Private Sub Command8_Click()
With cmbTEST
    .SetFocus
    .Dropdown
End With
End Sub

To review, my wish is to auto-expand my combo box when the form is first opened. When my application is completed, this form will be very busy, so I want the user to see that they must select from the combo box to display records, then have that list collapse once the selection is made (hence my choice of a combo box over an expanded list box).
 
Upvote 0
I want the user to see that they must select from the combo box to display records, then have that list collapse once the selection is made (hence my choice of a combo box over an expanded list box).

Perhaps instead you could color all required fields a different color (set BackColor property to vbRed) or similar. Then set the color back to "normal" when the data has been "verified".

btw, your code works fine in 2003.

hth,

Rich
 
Upvote 0
For the benefit of anyone searching this post for an answer, the problem of .DropDown not working during form opening events was documented by Microsoft in Access 97 ("Dropdown Method of Combo Box Not Working in Load Event of Form"): http://support.microsoft.com/kb/181078

I found no mention of the problem for Access 2007, which I am using.

Thanks to all responders for your suggestions. I'll need to take a different approach.:(
 
Last edited:
Upvote 0

Forum statistics

Threads
1,222,827
Messages
6,168,482
Members
452,192
Latest member
FengXue

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top