Is there a way to tell if a combbox is in dropdown mode.
I tried and if statement combobox.dropdown = true
but i get an error. dropwndown function doesnt store if its true or
false
what i am trying to do is make an autoscroll combobox. like you have on
html textbox's, but this time you hit enter for a change to be made. i
do this because i dont want to requery every time a single letter is
inputed. it would be too slow. so i make them hit enter when they are
ready to search.
you type something in the combox, hit enter, and the combobox refreshes
itself with the new data. then you can choose an item from the dropdown
but this time when you hit enter again rather then refresh the
combobox rowsource, i want the combobox to finally update and move on.
If i had a activecontrol.dropdown state return true or false i would
tell it to update rowsource when activecontrol.dropdown = false and to
update field when activecontrol.dropdown = true.
But i dont have that so i came up with this longggg way...
heres how i did it:
'WHEN YOU HIT ENTER REFRESH THE ROWSOURCE WITH NEW CRITERIA AND
'SET DROPDOWN VARIABLE TO TRUE
Dim onEnter as boolean ' Lets me know if enter was hit already
Dim onDropDown as Boolean ' Lets me know if the combobox is in dropdown
state
Private Sub COMBOBOX1_KeyDown(KeyCode As Integer, Shift As Integer)
If IsNull(Me.COMBOBOX1.Text) Then Exit Sub
Select Case KeyCode
Case 13 'enter
If onDropDown = False Then
Dim strRow As String
Dim x As Integer
Dim strStr1 As String
onEnter = True
Me.COMBOBOX1.SetFocus
x = Nz(Me.txtSTNUM1)
str1 = Me.COMBOBOX1.Text
strRow = "SELECT * WHERE COMBO LIKE '" & Str1 &"' & '*' "
Me.COMBOBOX1.RowSource = strRow
End If
Case 37, 38, 39, 40, 9 'IF ANY KEY IS HIT OTHER THAN ARROW KEYS AND TAB
THEN
Case Else
If onDropDown = True Then onDropDown = False 'RESET DROPDOWN STATE
End Select
End Sub
'WHEN YOU GET FOCUS RESET DROPDOWN STATE
Private Sub COMBOBOX1_GotFocus()
If onDropDown = True Then onDropDown = False
End Sub
'WHEN YOU HIT ENTER YOUR AUTOMATICALLY LOOSE THE FOCUS SO
'WHEN YOU LOOSE FOCUS DURING DROPDOWN STATE BRING THE FOCUS BACK
Private Sub COMBOBOX1_Exit(Cancel As Integer)
If onEnter Then
onDropDown = True
onEnter = False
Me.TEXTBOX.SetFocus 'YOU HAVE TO SET FOCUS TO SOMETHING ELSE FIRST
Me.COMBOBOX1.SetFocus
Call PutCursorAtEnd 'THIS FUNCTION PUTS CURSOR AT END OF CONTROL
Me.COMBOBOX1.Dropdown
End If
End Sub
if someone has a better idea please let me know
Thanks!