Combo Box Navigation Problem

  • Thread starter Tim C via AccessMonster.com
  • Start date
T

Tim C via AccessMonster.com

I'm trying to use the down/up arrow navigation keys on a standard combo box
(ie. open combo box, scroll to correct selection and press enter to select
and close). When I set focus on the box and press F4 or alt/down arrow to
push the drop down, and press the down arrow, the dropdown closes. When i
press F4 or alt/down arrow again on the combo box I am able to scroll through
the list with the arrow keys with no problem and make my selection. I've
turned off all events for the form and the combo box and still get the same
results.

Any suggestions on why I have to use F4 or alt/down arrow a second time?
 
A

Albert D.Kallal

When I set focus on the box and press F4 or alt/down arrow to
push the drop down, and press the down arrow, the dropdown closes.

I am not seeing the above behaviors. Perhaps you are using code to set the
focus?

If you are, then I would suggest your code do


me.myCombobox.SetFocuse
me.MyComboBox.DropDown

The above should do the trick. If you are using sendkeys..then I suspect
some other issue is getting in the way

Anyway, you are much better off to use built-in methods then use send keys.

If the above don't fix your form..then I would be suspect of a timer event
running.....
 
T

Tim C via AccessMonster.com

Albert said:
I am not seeing the above behaviors. Perhaps you are using code to set the
focus?

If you are, then I would suggest your code do

me.myCombobox.SetFocuse
me.MyComboBox.DropDown

The above should do the trick. If you are using sendkeys..then I suspect
some other issue is getting in the way

Anyway, you are much better off to use built-in methods then use send keys.

If the above don't fix your form..then I would be suspect of a timer event
running.....
Thanks for responding Albert

I originally wrote a macro and autokey to achieve my initial post and have
disabled my timer event. I have been using F4 to break the problem down to
it's most basic elements. My code in the function module is

Forms![frm_incoming_input].Cmbo_Material.SetFocus
Forms![frm_incoming_input].Cmbo_Material.Dropdown

and my autokey is set to F2

One thing I have noticed is my form seems to refresh when I press the down
arrow on my first try, I've check my form events and disabled all my refresh
and requery routines to make sure I'm not triggering the problems, but get
the same results. Do you know of anything in the Access setup that would
refresh my screen on dirty withou my calling it?

Thanks

Thanks
 
A

Albert D.Kallal

disabled my timer event.

Does that mean you were using a timer event then???
I have been using F4 to break the problem down to
it's most basic elements. My code in the function module is

Forms![frm_incoming_input].Cmbo_Material.SetFocus
Forms![frm_incoming_input].Cmbo_Material.Dropdown

and my autokey is set to F2

hum...I have not idea what you mean by autokey is set to f2? What autokey??

Do you mean that you want the f2 key to call the above code?

Since you hard coded the above forms and field names, then why not put the
code in the forms module?

In act, I would use the forms keydown event. In the forms property sheet,
set the key preview to "yes"
(this "yes" setting means that the code can grab the key stroke BEFORE any
field, or form, or anything else
on the form.

For the key down event, and to have the f2 key set focus to your combo
box..you would use:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyF2 Then

KeyCode = 0 ' flush the key beofre anything else can see it...

me.Cmbo_Material.SetFocus
me.Cmbo_Material.Dropdown

End Sub

I am not sure ..but My guess is that a keystroke is still in the buffer...or
it is still being seen/processed by the form. In fact, likely the code
runs..and the key is still seen by the form (after the code runs!!).

Anyway, the above is a clean approach, traps the keystroke, and keeps the
code in the ONE form..so you don't have a funny autokeys macro trying to run
when the form is not loaded etc.
 
T

Tim C via AccessMonster.com

Albert said:
disabled my timer event.

Does that mean you were using a timer event then???
I have been using F4 to break the problem down to
it's most basic elements. My code in the function module is
[quoted text clipped - 3 lines]
and my autokey is set to F2

hum...I have not idea what you mean by autokey is set to f2? What autokey??

Do you mean that you want the f2 key to call the above code?

Since you hard coded the above forms and field names, then why not put the
code in the forms module?

In act, I would use the forms keydown event. In the forms property sheet,
set the key preview to "yes"
(this "yes" setting means that the code can grab the key stroke BEFORE any
field, or form, or anything else
on the form.

For the key down event, and to have the f2 key set focus to your combo
box..you would use:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyF2 Then

KeyCode = 0 ' flush the key beofre anything else can see it...

me.Cmbo_Material.SetFocus
me.Cmbo_Material.Dropdown

End Sub

I am not sure ..but My guess is that a keystroke is still in the buffer...or
it is still being seen/processed by the form. In fact, likely the code
runs..and the key is still seen by the form (after the code runs!!).

Anyway, the above is a clean approach, traps the keystroke, and keeps the
code in the ONE form..so you don't have a funny autokeys macro trying to run
when the form is not loaded etc.
Hi Albert
Thanks for your additional input to my problem. I got my original code to
work by adding

Me.Cmbo_Material = "OCC (Old Corrigated Cardboard)"

to my event code, along with the original "setfocus" and "Dropdown". I
wanted the dropdown to goto this item
any way to get the user closer to the item they may want to select for the
particular material type.

I did change my event to your recommended "VbKey" routine but unfortunately
without storing the "OCC (Old Corrigated Cardboard)" variable to the combo
box it gave me the same problem, I like your solution better than the macro
and autokey method, due to it won't execute on a non-related form. Even
though I would have liked to know why it originally didn't work correctly I
can live with the fact that I don't.

Any way it works correctly now and I appreciate your help.
 

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