Dropdown not working

G

Guest

Using MS Access 2K on Windows XP.

I have a form with a bound text control and an unbound comb-box. The
combo-box is transparent and placed "behind" the text control.

What I'd like to happen is that when the text control gets focus, if there
is no value in it, then have the combo-box drop down.

In the "Get Focus" of text control, I have the following code:
==========================
If IsNull(Me.txtElement) Then
Me.cboElement.SetFocus
End If
==========================

In the "Get Focus" of combo-box, I have the following code:
============================
MsgBox "Inside cbo got focus"
Me.cboElement.Dropdown
============================

When I enter the form, the focus shifts to the combo-box, but it does not
drop down.

Am I missing something here? Will appreciate any help.

-Amit
 
K

Ken Snell [MVP]

Actually, in my testing, the dropdown list does show for a moment, and then
it disappears. Testing shows that this is because you're setting focus to
the combo box from the textbox's GotFocus event. If you skip the textbox
code and go directly to the combo box, it will drop down the list as you
desire.

I have tried various things, but have been unsuccessful at keeping the
dropdown list "open" by using a textbox to set focus to the combo box. You
can do it if you use the Exit event of the control just in front of the
textbox in the tab order to test the contents of the textbox, and if it's
empty, make that textbox invisible so that the combo box would be the next
control to receive the focus. This means that your tab order must have the
combo box right after the textbox whose contents you're testing. You also
would need code to make that textbox visible again at some point.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top