Combo Box control with keyboard keys

J

Jasper Recto

I have a form with a text box and a combo box. The combo box is the second
item in the tab order next to the text box.

Is it possible to have the combo box list the items out as soon as you tab
over to it?

I would like it to list the items when you tab over to it and allow you to
move up and down the list using the keyboard arrows or event he mouse scroll
button.

And then, once the user has highlighted the item they want, I would like
them to press the enter button and have it tab over to the next item.

Is this possible?

Thanks,
Jasper
 
W

Wayne-I-M

Is it possible to have the combo box list the items out as soon as you tab
over to it?

Private Sub ComboName_Enter()
Me.ComboName.Dropdown
End Sub
And then, once the user has highlighted the item they want, I would like
them to press the enter button and have it tab over to the next item.

You don't need to code the next tab (unless there is a reason to do this -
like if me.xxx=123.go somewhere else if me.xxx=abc.do something else)

Private Sub ComboName_AfterUpdate()
If Me.ComboName = "ABC" Then
Me.SomeControl.SetFocus
Else
Me.SomeOtherControl.SetFocus
End If
End Sub

Best bet would be to set the tab stops in the right order and this will do
it for you.
I would like it to list the items when you tab over to it and allow you to
move up and down the list using the keyboard arrows or event he mouse scroll
button.

It should do that anyway
 
S

strive4peace

Hi Jasper,

here are two procedures I have in the general library I import into
every database application:

'~~~~~~~~~~~~~~~~~~~~~~~~~~ DropMe
Function DropMe(Optional bSetToNull As Boolean = False) As Byte
On Error GoTo Proc_Err
'usually used on the MouseUp event of a Combo Box
'so you can click anywhere and drop the list
'instead of just on the arrow
'=DropMe()

If bSetToNull Then
Screen.ActiveControl = Null
End If

Screen.ActiveControl.Dropdown
Exit Function
Proc_Err:
MsgBox Err.Number & " " & Err.Description, , "Cannot drop list right
now"
End Function

'~~~~~~~~~~~~~~~~~~~~~~~~~~ DropMeIfNull
Function DropMeIfNull() As Byte
'usually used on the GotFocus event of a Combo Box
'so if there is nothing filled out yet, the list will drop
'Do NOT use on the first control in the tab order
'=DropMeIfNull()

On Error Resume Next
If IsNull(Screen.ActiveControl) Then Screen.ActiveControl.Dropdown
Exit Function
End Function

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

rather than setting a specific control to go to after you update the
combo, you should set the TAB ORDER of the form:

from the design view, right-click on the Detail section bar (or in the
detail section that is not a control) and choose --> 'Tab Order' from
the shortcut menu

if there are controls you do not want the user to change, set the Tab
Stop property to False or No ('Other' or 'All' tab of Properties window)

for better understanding of the basics of Access, read this:

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace


Warm Regards,
Crystal

remote programming and training

*
:) have an awesome day :)
*
 
S

strive4peace

Hi Jasper,

the code goes into a general module -- so it is accessible from anywhere

then, to use the DropMe procedure, follow the instructions at the top of
the procedure:

'usually used on the MouseUp event of a Combo Box
'so you can click anywhere and drop the list
'instead of just on the arrow
'=DropMe()

It is not a good idea to automatically drop a list unless there is no
choice yet -- instructions for running DropMeIfNull are, once again, in
comment lines in the code

**********************************************************
*** How to Create a Standard (General) Module ***

1. from the database window, click on the Module tab
2. click on the NEW command button
3. type (or paste) the code in

once the code is in the module sheet, from the menu, do -->
Debug,Compile

if there are no syntax/reference errors, nothing will appear to happen
-- in this case, nothing happening is good <g>

Make sure to give the module a good name when you save it. You can have
several procedures (Subs and Functions) in a module, which gives you a
way to categorize them ... ie: basic procedures that would be useful in
any database; procedures that are specific to a particular database;
procedures for converting data; etc

~~~

It would be a good idea for you to read this:

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace


Warm Regards,
Crystal

*
:) have an awesome day :)
*
 

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

Similar Threads


Top