From: BillD on
I have a combo box that I would like to use the arrow keys on my keyboard to
navigate through. The combo box is to select states. When I type in the first
letter I get for example Maine. I would like to be able to use my arrow keys
to move to another state for example Minnesota.

I was give a code to type in but I now get a run time error 424 whenever I
try to enter anything in the texbox or use the arrow on the text box.
The error code reads: Run Time Error '424'; Object Required.
When I click on the debug button I get the code which is below and the line
"If KeyCode = VbKeyDown and Combobox.ListIndex <> Combobox.ListCount - 1
Then" is highlighted in yellow. I did a copy paste so the below code is
exactly as it appears in my database.

Private Sub CoState_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown And ComboBox.ListIndex <> ComboBox.ListCount - 1 Then
ComboBox.ListIndex = ComboBox.ListIndex + 1
End If
If KeyCode = vbKeyUp And ComboBox.ListIndex <> -1 Then
ComboBox.ListIndex = ComboBox.ListIndex - 1
End If
End Sub

I am still learning Acess so if you could explain what I need to do in
simple terms I would appreciate it.

Thank you for your time and help




--
BillD
From: Bob Gajewski on
Bill

Couple of options here.

1) If you do not have AutoComplete set to yes, subsequent pressing of the
"M" key (in your specific example) will cycle through all of the "M" states.

2) If you press F4 while in the combobox, it will dropdown and you can use
the arrow keys to navigate up and down.

3) You can set the combobox to automatically dropdown when entering, and
then you can use the arrow keys to navigate up and down.

I prefer option #2, but try them all first and see which you like.

Regards,
Bob Gajewski

"BillD" wrote:

> I have a combo box that I would like to use the arrow keys on my keyboard to
> navigate through. The combo box is to select states. When I type in the first
> letter I get for example Maine. I would like to be able to use my arrow keys
> to move to another state for example Minnesota.
>
> I was give a code to type in but I now get a run time error 424 whenever I
> try to enter anything in the texbox or use the arrow on the text box.
> The error code reads: Run Time Error '424'; Object Required.
> When I click on the debug button I get the code which is below and the line
> "If KeyCode = VbKeyDown and Combobox.ListIndex <> Combobox.ListCount - 1
> Then" is highlighted in yellow. I did a copy paste so the below code is
> exactly as it appears in my database.
>
> Private Sub CoState_KeyDown(KeyCode As Integer, Shift As Integer)
> If KeyCode = vbKeyDown And ComboBox.ListIndex <> ComboBox.ListCount - 1 Then
> ComboBox.ListIndex = ComboBox.ListIndex + 1
> End If
> If KeyCode = vbKeyUp And ComboBox.ListIndex <> -1 Then
> ComboBox.ListIndex = ComboBox.ListIndex - 1
> End If
> End Sub
>
> I am still learning Acess so if you could explain what I need to do in
> simple terms I would appreciate it.
>
> Thank you for your time and help
>
>
>
>
> --
> BillD
From: BillD on
Where do I find the autocomplete. I looked in the properties and did not see
any option titled "Autocomplete". Also if I wanted to try option 3 how do I
set the combobox to automatically drop down when I enter a letter in the box.

I have tried option 2 and that works ok, but would like to try the others
also to see which works the best for me

Thanks
--
BillD


"Bob Gajewski" wrote:

> Bill
>
> Couple of options here.
>
> 1) If you do not have AutoComplete set to yes, subsequent pressing of the
> "M" key (in your specific example) will cycle through all of the "M" states.
>
> 2) If you press F4 while in the combobox, it will dropdown and you can use
> the arrow keys to navigate up and down.
>
> 3) You can set the combobox to automatically dropdown when entering, and
> then you can use the arrow keys to navigate up and down.
>
> I prefer option #2, but try them all first and see which you like.
>
> Regards,
> Bob Gajewski
>
> "BillD" wrote:
>
> > I have a combo box that I would like to use the arrow keys on my keyboard to
> > navigate through. The combo box is to select states. When I type in the first
> > letter I get for example Maine. I would like to be able to use my arrow keys
> > to move to another state for example Minnesota.
> >
> > I was give a code to type in but I now get a run time error 424 whenever I
> > try to enter anything in the texbox or use the arrow on the text box.
> > The error code reads: Run Time Error '424'; Object Required.
> > When I click on the debug button I get the code which is below and the line
> > "If KeyCode = VbKeyDown and Combobox.ListIndex <> Combobox.ListCount - 1
> > Then" is highlighted in yellow. I did a copy paste so the below code is
> > exactly as it appears in my database.
> >
> > Private Sub CoState_KeyDown(KeyCode As Integer, Shift As Integer)
> > If KeyCode = vbKeyDown And ComboBox.ListIndex <> ComboBox.ListCount - 1 Then
> > ComboBox.ListIndex = ComboBox.ListIndex + 1
> > End If
> > If KeyCode = vbKeyUp And ComboBox.ListIndex <> -1 Then
> > ComboBox.ListIndex = ComboBox.ListIndex - 1
> > End If
> > End Sub
> >
> > I am still learning Acess so if you could explain what I need to do in
> > simple terms I would appreciate it.
> >
> > Thank you for your time and help
> >
> >
> >
> >
> > --
> > BillD
From: Bob Gajewski on
Sorry, Bill - terminology error. The property is "Auto Expand", not
autocomplete. And I'm not so sure that this one works the right way.

The other is a property you set in code. Using the OnEnter and/or GotFocus
events, just put:

cboStateCode.Dropdown = True

Regards,
Bob


"BillD" wrote:

> Where do I find the autocomplete. I looked in the properties and did not see
> any option titled "Autocomplete". Also if I wanted to try option 3 how do I
> set the combobox to automatically drop down when I enter a letter in the box.
>
> I have tried option 2 and that works ok, but would like to try the others
> also to see which works the best for me
>
> Thanks
> --
> BillD
>
>
> "Bob Gajewski" wrote:
>
> > Bill
> >
> > Couple of options here.
> >
> > 1) If you do not have AutoComplete set to yes, subsequent pressing of the
> > "M" key (in your specific example) will cycle through all of the "M" states.
> >
> > 2) If you press F4 while in the combobox, it will dropdown and you can use
> > the arrow keys to navigate up and down.
> >
> > 3) You can set the combobox to automatically dropdown when entering, and
> > then you can use the arrow keys to navigate up and down.
> >
> > I prefer option #2, but try them all first and see which you like.
> >
> > Regards,
> > Bob Gajewski
> >
> > "BillD" wrote:
> >
> > > I have a combo box that I would like to use the arrow keys on my keyboard to
> > > navigate through. The combo box is to select states. When I type in the first
> > > letter I get for example Maine. I would like to be able to use my arrow keys
> > > to move to another state for example Minnesota.
> > >
> > > I was give a code to type in but I now get a run time error 424 whenever I
> > > try to enter anything in the texbox or use the arrow on the text box.
> > > The error code reads: Run Time Error '424'; Object Required.
> > > When I click on the debug button I get the code which is below and the line
> > > "If KeyCode = VbKeyDown and Combobox.ListIndex <> Combobox.ListCount - 1
> > > Then" is highlighted in yellow. I did a copy paste so the below code is
> > > exactly as it appears in my database.
> > >
> > > Private Sub CoState_KeyDown(KeyCode As Integer, Shift As Integer)
> > > If KeyCode = vbKeyDown And ComboBox.ListIndex <> ComboBox.ListCount - 1 Then
> > > ComboBox.ListIndex = ComboBox.ListIndex + 1
> > > End If
> > > If KeyCode = vbKeyUp And ComboBox.ListIndex <> -1 Then
> > > ComboBox.ListIndex = ComboBox.ListIndex - 1
> > > End If
> > > End Sub
> > >
> > > I am still learning Acess so if you could explain what I need to do in
> > > simple terms I would appreciate it.
> > >
> > > Thank you for your time and help
> > >
> > >
> > >
> > >
> > > --
> > > BillD
From: Douglas J. Steele on
What's the name of your combo box? The name of the routine is
CoState_KeyDown, which implies that the combo box is named CoState, yet
you're using ComboBox.ListIndex inside the routine.

Try changing ComboBox.ListIndex to CoState.ListIndex or, better,
Me!CoState.ListIndex.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"BillD" <BillD(a)discussions.microsoft.com> wrote in message
news:945FE6E6-6725-41E8-95B4-68461BE04255(a)microsoft.com...
>I have a combo box that I would like to use the arrow keys on my keyboard
>to
> navigate through. The combo box is to select states. When I type in the
> first
> letter I get for example Maine. I would like to be able to use my arrow
> keys
> to move to another state for example Minnesota.
>
> I was give a code to type in but I now get a run time error 424 whenever I
> try to enter anything in the texbox or use the arrow on the text box.
> The error code reads: Run Time Error '424'; Object Required.
> When I click on the debug button I get the code which is below and the
> line
> "If KeyCode = VbKeyDown and Combobox.ListIndex <> Combobox.ListCount - 1
> Then" is highlighted in yellow. I did a copy paste so the below code is
> exactly as it appears in my database.
>
> Private Sub CoState_KeyDown(KeyCode As Integer, Shift As Integer)
> If KeyCode = vbKeyDown And ComboBox.ListIndex <> ComboBox.ListCount - 1
> Then
> ComboBox.ListIndex = ComboBox.ListIndex + 1
> End If
> If KeyCode = vbKeyUp And ComboBox.ListIndex <> -1 Then
> ComboBox.ListIndex = ComboBox.ListIndex - 1
> End If
> End Sub
>
> I am still learning Acess so if you could explain what I need to do in
> simple terms I would appreciate it.
>
> Thank you for your time and help
>
>
>
>
> --
> BillD