Option group button navigation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an option group that has option buttons in columns. When the user
uses the up/down arrow keys to navigate between buttons, the cursor/focus
doesn't go up/down one column and then the other. Instead it hopps back and
forth between the columns. How can this be fixed? (This is similar to the
tab order idea in a regular form, which can easily be adjusted, but I don't
see anything like this for "option button order".)
 
I've played with this a little bit; it looks as if the cursor always goes to
the next option whose Top property is >= the current option.
Short of writing code in the KeyDown event for each option button to capture
and redirect each arrow key, I don't see any easy way to change this
behavior.
 
Thanks for checking this out for me. I have verified that your observation
is correct. Who would have thunk it!!

So let's say I wanted to write code as you suggest, I would do a " If
KeyCode = vbKeyDown Then ... " for instance, but how would you set the focus
to the desired option button control? Is there a way to use the Option Value
property of the option buttons to redirect it from code? Or the Tag property
maybe?

ctdak
 
Assuming that the OptionValue of your buttons increments by 1 in the order
you want your focus to move, you could use something simple like
if KeyCode=vbKeyDown then MyFrame=MyFrame+1

You can write a single function that processes all the keys you want to
trap, then pass it the KeyCode from each KeyDown event...

Oh, and be sure to set
KeyCode=0
afterwards, to avoid further processing of that keystroke...
 
My installation of Access/VB does not recognize MyFrame as a keyword. I
don't find any reference to it in help info either. What is MyFrame and why
aren't I able to use it?
ctdak
 
"MyFrame" is a name I used because I didn't know the name of the Option
Group you have.
Just put the name of the Option Group (the control which contains your
buttons) wherever I've used MyFrame. (If the name contains non-standard
characters, use [square brackets] around it.)
 
OK, thanks. Since MyFrame didn't sound like OptionGroup, I thought it must
be something I was unfamiliar with. I got the code to work using your input
- much appreciated! I didn't know that the OptionGroup name would carry with
it the value of the current option button, or that the focus would move to an
option button by just adding a numeric value to the name. I don't know why
this works but it does.
ctdak


MacDermott said:
"MyFrame" is a name I used because I didn't know the name of the Option
Group you have.
Just put the name of the Option Group (the control which contains your
buttons) wherever I've used MyFrame. (If the name contains non-standard
characters, use [square brackets] around it.)

ctdak said:
My installation of Access/VB does not recognize MyFrame as a keyword. I
don't find any reference to it in help info either. What is MyFrame and why
aren't I able to use it?
ctdak
 
I think having the value of the current option available as a property of
the Option Group (I think the default name is Frame1) is one of the most
useful things about it. Think of it this way: if you set the value of the
Option Group, you're telling it what button to show as selected. (You can
set the value to something that's not the OptionValue for any button, and no
button will be selected.) So when you increment the value of the Option
Group, it automatically shows the "next" button as selected. You can
control it by changing the OptionValues of the various buttons.

HTH

ctdak said:
OK, thanks. Since MyFrame didn't sound like OptionGroup, I thought it must
be something I was unfamiliar with. I got the code to work using your input
- much appreciated! I didn't know that the OptionGroup name would carry with
it the value of the current option button, or that the focus would move to an
option button by just adding a numeric value to the name. I don't know why
this works but it does.
ctdak


MacDermott said:
"MyFrame" is a name I used because I didn't know the name of the Option
Group you have.
Just put the name of the Option Group (the control which contains your
buttons) wherever I've used MyFrame. (If the name contains non-standard
characters, use [square brackets] around it.)

ctdak said:
My installation of Access/VB does not recognize MyFrame as a keyword. I
don't find any reference to it in help info either. What is MyFrame
and
why
aren't I able to use it?
ctdak


:

Assuming that the OptionValue of your buttons increments by 1 in the order
you want your focus to move, you could use something simple like
if KeyCode=vbKeyDown then MyFrame=MyFrame+1

You can write a single function that processes all the keys you want to
trap, then pass it the KeyCode from each KeyDown event...

Oh, and be sure to set
KeyCode=0
afterwards, to avoid further processing of that keystroke...


Thanks for checking this out for me. I have verified that your
observation
is correct. Who would have thunk it!!

So let's say I wanted to write code as you suggest, I would do a " If
KeyCode = vbKeyDown Then ... " for instance, but how would you set the
focus
to the desired option button control? Is there a way to use the Option
Value
property of the option buttons to redirect it from code? Or the Tag
property
maybe?

ctdak

:

I've played with this a little bit; it looks as if the cursor always
goes to
the next option whose Top property is >= the current option.
Short of writing code in the KeyDown event for each option button to
capture
and redirect each arrow key, I don't see any easy way to change this
behavior.

I have an option group that has option buttons in columns.
When
the
user
uses the up/down arrow keys to navigate between buttons, the
cursor/focus
doesn't go up/down one column and then the other. Instead it hopps
back
and
forth between the columns. How can this be fixed? (This is similar
to
the
tab order idea in a regular form, which can easily be
adjusted,
but I
don't
see anything like this for "option button order".)
 
Thanks a lot for the explanation.
ctdak


MacDermott said:
I think having the value of the current option available as a property of
the Option Group (I think the default name is Frame1) is one of the most
useful things about it. Think of it this way: if you set the value of the
Option Group, you're telling it what button to show as selected. (You can
set the value to something that's not the OptionValue for any button, and no
button will be selected.) So when you increment the value of the Option
Group, it automatically shows the "next" button as selected. You can
control it by changing the OptionValues of the various buttons.

HTH

ctdak said:
OK, thanks. Since MyFrame didn't sound like OptionGroup, I thought it must
be something I was unfamiliar with. I got the code to work using your input
- much appreciated! I didn't know that the OptionGroup name would carry with
it the value of the current option button, or that the focus would move to an
option button by just adding a numeric value to the name. I don't know why
this works but it does.
ctdak


MacDermott said:
"MyFrame" is a name I used because I didn't know the name of the Option
Group you have.
Just put the name of the Option Group (the control which contains your
buttons) wherever I've used MyFrame. (If the name contains non-standard
characters, use [square brackets] around it.)

My installation of Access/VB does not recognize MyFrame as a keyword. I
don't find any reference to it in help info either. What is MyFrame and
why
aren't I able to use it?
ctdak


:

Assuming that the OptionValue of your buttons increments by 1 in the
order
you want your focus to move, you could use something simple like
if KeyCode=vbKeyDown then MyFrame=MyFrame+1

You can write a single function that processes all the keys you want to
trap, then pass it the KeyCode from each KeyDown event...

Oh, and be sure to set
KeyCode=0
afterwards, to avoid further processing of that keystroke...


Thanks for checking this out for me. I have verified that your
observation
is correct. Who would have thunk it!!

So let's say I wanted to write code as you suggest, I would do a " If
KeyCode = vbKeyDown Then ... " for instance, but how would you set the
focus
to the desired option button control? Is there a way to use the
Option
Value
property of the option buttons to redirect it from code? Or the Tag
property
maybe?

ctdak

:

I've played with this a little bit; it looks as if the cursor always
goes to
the next option whose Top property is >= the current option.
Short of writing code in the KeyDown event for each option button to
capture
and redirect each arrow key, I don't see any easy way to change this
behavior.

I have an option group that has option buttons in columns. When
the
user
uses the up/down arrow keys to navigate between buttons, the
cursor/focus
doesn't go up/down one column and then the other. Instead it
hopps
back
and
forth between the columns. How can this be fixed? (This is
similar
to
the
tab order idea in a regular form, which can easily be adjusted,
but I
don't
see anything like this for "option button order".)
 
Back
Top