Thread: Keydown issue
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Keydown issue


Try the below (untested)


Sub ControlForms(varCode)

If Chr(varCode) = "A" Then
Unload AddOrFind
AddTitle.Show
ElseIf Chr(varCode) = "F" Then
Unload AddOrFind
Search.Show
ElseIf Chr(varCode) = "V" Then
Unload AddOrFind
Summary.Show
End If

End Sub

Private Sub AddButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
ControlForms keycode
End Sub

Private Sub FindButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
ControlForms keycode
End Sub

Private Sub SummaryButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
ControlForms keycode
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

I have a userform with 3 buttons and the following code:

Private Sub AddButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

Dim A As Integer

If Chr(KeyCode) = "A" Then
Unload AddOrFind
AddTitle.Show
End If

End Sub


Private Sub FindButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

Dim A As Integer

If Chr(KeyCode) = "F" Then
Unload AddOrFind
Search.Show
End If

End Sub


Private Sub SummaryButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

Dim A As Integer

If Chr(KeyCode) = "V" Then
Unload AddOrFind
Summary.Show
End If

End Sub

The userform initiates with the first button active. If I press "a" then I
get the desired result. But the other two buttons do no respond to the
keydown unless I tab to that button to make it active. I would like to be
able to press any of the 3 buttons without having to tab. How do I
accomplish this?