Hi okaizawa
Thats cool! Prime objective reached.
1. I can maintain the labels, which in a number of cases have to be above
the optbutton (hence no button captions).
2. It saves a key depression in operation, which with a detailed data entry
form saves time and patience - every little bit helps.
Again thanks to all for their help. Two solutions for one problem can't be
bad.
Geoff
"okaizawa" wrote:
Hi,
what about something like this:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As
Long) As Integer
Private Sub OptionButton1_Enter()
If GetAsyncKeyState(vbKeyMenu) And &H8000 Then OptionButton1.Value =
True
End Sub
Private Sub OptionButton1_KeyDown(ByVal KeyCode As
MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = Asc(UCase(Label1.Accelerator)) And Shift = 4 Then
OptionButton1.Value = True
End Sub
Private Sub OptionButton2_Enter()
If GetAsyncKeyState(vbKeyMenu) And &H8000 Then OptionButton2.Value =
True
End Sub
Private Sub OptionButton2_KeyDown(ByVal KeyCode As
MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = Asc(UCase(Label2.Accelerator)) And Shift = 4 Then
OptionButton2.Value = True
End Sub
--
HTH
okaizawa
Geoff wrote:
On further testing of Accelerator I have a problem.
I use a label to name an optbutton rather than its caption. When I set an
accelerator on the optbutton the function works fine. If I set an
accelerator on the label it does not, yet according to VB Help: 'If the
accelerator applies to a Label, the control following the Label in the tab
order, rather than the Label itself, receives the focus.'
Any further suggestions other than use the optbutton caption?
Geoff