Combo boxes Once Again

T

TeeSee

I have a combo box on a main form as a lookup for a subform which
performs as expected (to a degree), however have the following
questions ......

1) Can I assume that if cboMyComboBox is at the top of the tab order
it will receive "focus" when the form opens?

2) How do I get it to drop ONLY when I first "enter" the
cboMyComboBox?

I have tried OnEnter to the cbo only to find (I think) that because it
"has focus" is the same as onEnter and the cbo drops.

I just don't like the look of opening a form and a great gaping cbo is
staring at you.

Any thoughts as always appreciated.
 
M

Marshall Barton

TeeSee said:
I have a combo box on a main form as a lookup for a subform which
performs as expected (to a degree), however have the following
questions ......

1) Can I assume that if cboMyComboBox is at the top of the tab order
it will receive "focus" when the form opens?

2) How do I get it to drop ONLY when I first "enter" the
cboMyComboBox?

I have tried OnEnter to the cbo only to find (I think) that because it
"has focus" is the same as onEnter and the cbo drops.

I just don't like the look of opening a form and a great gaping cbo is
staring at you.


The only times I have seen that behavior is when the
GotFocus or Enter event uses the combo box's DropDown
method.

I guess it could also happen if you have code to set the
combo box's Text property, but I don't think I ever tried
that.
 
T

TeeSee

TeeSee said:
I have a combo box on a main form as a lookup for a subform which
performs as expected (to a degree), however have the following
questions ......
1) Can I assume that if cboMyComboBox is at the top of the tab order
it will receive "focus" when the form opens?
2) How do I get it to drop ONLY when I first "enter" the
cboMyComboBox?
I have tried OnEnter to the cbo only to find (I think) that because it
"has focus" is the same as onEnter and the cbo drops.
I just don't like the look of opening a form and a great gaping cbo is
staring at you.

The only times I have seen that behavior is when the
GotFocus or Enter event uses the combo box's DropDown
method.

I guess it could also happen if you have code to set the
combo box's Text property, but I don't think I ever tried
that.

--
Marsh
MVP [MS Access]- Hide quoted text -

- Show quoted text -

Hi Marshall ... Thanks for the response

If I have no code in the open or load events my cbo seems to get focus
automatically since it is the top of the list in tab order. I tested
that by removing all related code.
With no other changes other than adding code to the OnEnter event on
the cbo
me!MyCombo.Dropdown
the cbo drops right off the bat when the form becomes visible (which
is what I didn't want) That makes me deduce that gotFocus in the cbo
is the same as having entered it. Is that correct?

The only way I can resolve is to code the onKeyPress rather than the
OnEnter event. Any further thoughts???
 
M

Marshall Barton

TeeSee said:
If I have no code in the open or load events my cbo seems to get focus
automatically since it is the top of the list in tab order. I tested
that by removing all related code.
With no other changes other than adding code to the OnEnter event on
the cbo
me!MyCombo.Dropdown
the cbo drops right off the bat when the form becomes visible (which
is what I didn't want) That makes me deduce that gotFocus in the cbo
is the same as having entered it. Is that correct?

Not quite the same. The Enter event only fires when the
control is entered from somewhere else on its form. The
GotFocus event is supposed to fire whenever the focus moves
to the control from from any form. So, if you are bouncing
between two forms, the control could have many GotFocus
events but it would have only one Enter event
The only way I can resolve is to code the onKeyPress rather than the
OnEnter event. Any further thoughts???

You could use the Change event (or a Key event), but if the
user has to hit a key, then the combo box's AutoExpand
feature will drop the list.

A different idea would be to add a text box, set its Width
to 0 and put it first in the tab order.

Personally, I would forget about using DropDown and all this
fooling around in favor of just letting the combo box drop
itself in response to user actions.
 

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