Is it possible to hit a command button and have a drop down list drop down so the user can see all the choices without clicking on it first?
Thanks,
Dan
Printable View
Is it possible to hit a command button and have a drop down list drop down so the user can see all the choices without clicking on it first?
Thanks,
Dan
You could try having a hidden listbox under the button and use the following code.
Code:
Private Sub command1_Click()
list1.visible = True
End Sub
Or you can send a message to the combo box eg:
SendMessage Combo1.hWnd, CB_SHOWDROPDOWN, 0, 0
which does the same thing
- gaffa
Here are the functions you need in order for the code above to work.
Code:Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Const CB_SHOWDROPDOWN = &H14F
Thanks for the help Mathew and gaffa, but it doesn't do a thing.. I put Mathew's code in the module and put gaffa's code verbatum (except for putting in the proper combo box name) behind the command button but it doesn't do a thing..
Any ideas?
Thanks,
Dan
I was at skool when I posted, so I couldn't test it.
Try this:
By the way, Mathew = Matthew = two t's.Code:Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Long) As Long
Private Const CB_SHOWDROPDOWN = &H14F
Private Sub Command1_Click()
Dim lRet as long
lRet = SendMessage(Combo1.hwnd, CB_SHOWDROPDOWN, 1, ByVal 0&)
End Sub
Code:'drop down a combobox when it gains focus
Dim bAlreadyDown As Boolean
Private Sub Combo1_DropDown()
bAlreadyDown = True
End Sub
Private Sub Combo1_GotFocus()
If bAlreadyDown = False Then SendKeys ("{f4}")
bAlreadyDown = False
End Sub
Private Sub Combo1_LostFocus()
bAlreadyDown = False
End Sub
Private Sub Command1_Click()
Combo1.SetFocus
End Sub