Problem with ComboBoxes

J

John S. Ford, MD

I am working with Access 97 and have a form with a ComboBox (cboFirst), a
TabControl and a ComboBox (cboSecond) on the first tab. I also have a
"Sentinel CommandButton (cmdSentinel) between cboFirst and the TabControl.
The tab order of these controls is cboFirst, cmdSentinal, TabControl,
cboSecond and my goal is two-fold:

1) Have my user to be able to tab (or hit <return>) thereby navigating from
cboFirst to cboSecond with just the keyboard. This would save the user from
mouse-clicking while entering data.

2) Have cboSecond "dropdown" as soon as it receives the focus.

You can't tab or <return> "directly" from a control on the form to a control
residing on a tab so I'm using cmdSentinel as a intermediate control (a
Sentinel control) as documented in the book "Access 97 Expert Solutions"
with the following code:


Private Sub cmdSentinel_Enter()
cboSecond.SetFocus
End Sub

Private Sub cboSecond_GotFocus()
Me!cboSecond.Dropdown
End Sub


Goal 1) works perfectly. But unfortunately, cboSecond drops down for only
an instant and then closes on its own. Any idea why this happens?

John
 
G

Graham Mandeno

Hi John

I have no idea why this happens but, you're right, it's the same for me.

Perhaps you could use the KeyPress event of cboFirst:

Private Sub cboFirst_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyTab Or KeyCode = vbKeyReturn Then
cboSecond.SetFocus
KeyCode = 0
End If
End Sub

It seems to work, and it's a lot cleaner because you can do away with the
kludgey command button.
 

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