How to tell if combo box is dropped down (1 Viewer)

ListO

Señor Member
Local time
Today, 10:08
Joined
Feb 2, 2000
Messages
162
Is there a way to determine if at any moment a combo box is in the dropped-down state or not?

I've got code which redirects keystrokes, and I'd like to have it not re-direct up- and down- arrows when a combo box is dropped down so that the combo box appears to function normally, but I don't know how to determine when it's been opened (F4).
 

RFigaro

Registered User.
Local time
Today, 02:08
Joined
Aug 5, 2012
Messages
18
I am having the same problem. Were you able to solve this and if so how did you do it. There must be an easier way other than using the code linked to above.

Thank you,
RFig
 

ListO

Señor Member
Local time
Today, 10:08
Joined
Feb 2, 2000
Messages
162
Wow- good for you to search back for this solution!

I did not find a better way to do this. It was pretty easy to paste the module into my program, then it only requires a call to fIsComboOpen to check for open combobox.

If it helps, here is the code I use within the form. It is called in the OnKeyDown property of each control. i.e. for a combobox named "ReelID" the OnKeyDown triggers this code:
Code:
Private Sub ReelID_KeyDown(KeyCode As Integer, Shift As Integer)
    KeyCheck (KeyCode)
End Sub

My KeyCheck code is:
Code:
Private Sub KeyCheck(KeyAscii As Integer)
On Error GoTo KeyCheckError
'-----------------------------------------------------------------------------
'Must use the keydown checks on each individual control because there is one control
'in the form header, and when it is active and an up- or down-arrow key is pressed,
'Access cannot go to the next record, because the control is not part of a record.

The variable RecCount holds the value of the number of records in the dynaset.
'-----------------------------------------------------------------------------
    DropDown = KeyAscii = vbKeyF4
    If DropDown Then GoTo Skipcheck
    If fIsComboOpen Then GoTo Skipcheck
    If KeyAscii = vbKeyUp And Me.CurrentRecord > 1 Then DoCmd.GoToRecord , , acPrevious
    If (KeyAscii = vbKeyDown Or KeyAscii = vbKeyReturn) And Me.CurrentRecord < RecCount Then DoCmd.GoToRecord , , acNext

Skipcheck:
    Exit Sub
KeyCheckError:
    If Err = 2105 Then
    DoCmd.GoToControl "ReelId"
End If

End Sub
I use this in only one form for my application, otherwise I'd make it a public function an call from other forms.

Good luck.
 

RFigaro

Registered User.
Local time
Today, 02:08
Joined
Aug 5, 2012
Messages
18
Thank you very much for the reply. I really appreciate you pasting the code you used as I am sure that will help me out a lot. I will give it a try.
 

Users who are viewing this thread

Top Bottom