Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() the keydown for all three buttons AND the userform call a check routine, passing the keycode. the check routine use SELECT to determine what to do ... Private Sub AddButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) CheckKey KeyCode End Sub Private Sub FindButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) CheckKey KeyCode End Sub Private Sub SummaryButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) CheckKey KeyCode End Sub Private Sub AddButton_Click() CheckKey KeyCode End Sub Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) CheckKey KeyCode End Sub Sub CheckKey(KeyCode As MSForms.ReturnInteger) Select Case Chr(KeyCode) Case "A" MsgBox "AddTitle" Case "V" MsgBox "Summary" Case "F" MsgBox "Find" End Select End Sub "Bishop" wrote in message ... 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? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Here is my actual code: Sub CheckKey(KeyCode As MSForms.ReturnInteger) Select Case Chr(KeyCode) Case "A" Unload AddOrFind AddTitle.Show Case "F" Unload AddOrFind GetTitle.Show Case "V" Unload AddOrFind Summary.Show End Select End Sub I'm getting Error 91 for GetTitle.Show. Any idea why? "Patrick Molloy" wrote: the keydown for all three buttons AND the userform call a check routine, passing the keycode. the check routine use SELECT to determine what to do ... Private Sub AddButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) CheckKey KeyCode End Sub Private Sub FindButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) CheckKey KeyCode End Sub Private Sub SummaryButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) CheckKey KeyCode End Sub Private Sub AddButton_Click() CheckKey KeyCode End Sub Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) CheckKey KeyCode End Sub Sub CheckKey(KeyCode As MSForms.ReturnInteger) Select Case Chr(KeyCode) Case "A" MsgBox "AddTitle" Case "V" MsgBox "Summary" Case "F" MsgBox "Find" End Select End Sub "Bishop" wrote in message ... 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? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Object variable or With block variable not set is the name of your form correct? "Bishop" wrote in message ... Here is my actual code: Sub CheckKey(KeyCode As MSForms.ReturnInteger) Select Case Chr(KeyCode) Case "A" Unload AddOrFind AddTitle.Show Case "F" Unload AddOrFind GetTitle.Show Case "V" Unload AddOrFind Summary.Show End Select End Sub I'm getting Error 91 for GetTitle.Show. Any idea why? "Patrick Molloy" wrote: the keydown for all three buttons AND the userform call a check routine, passing the keycode. the check routine use SELECT to determine what to do ... Private Sub AddButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) CheckKey KeyCode End Sub Private Sub FindButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) CheckKey KeyCode End Sub Private Sub SummaryButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) CheckKey KeyCode End Sub Private Sub AddButton_Click() CheckKey KeyCode End Sub Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) CheckKey KeyCode End Sub Sub CheckKey(KeyCode As MSForms.ReturnInteger) Select Case Chr(KeyCode) Case "A" MsgBox "AddTitle" Case "V" MsgBox "Summary" Case "F" MsgBox "Find" End Select End Sub "Bishop" wrote in message ... 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? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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? |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Still the same error. Weird. The other two work fine. The help file doesn't help either. "Jacob Skaria" wrote: 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? |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bishop
What are you trying to do here? By the way you might want to look at the Excel VBA help topic on these events. KeyCode doesn't return an ASCII/ANSI code. Note The KeyDown and KeyUp events apply only to forms and controls on a form. To interpret ANSI characters or to find out the ANSI character corresponding to the key pressed, use the KeyPress event. On Jun 29, 8:17*pm, Bishop wrote: Still the same error. *Weird. *The other two work fine. *The help file doesn't help either. "Jacob Skaria" wrote: 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?- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Here is the syntax for TreeView.KeyDown(). | Excel Programming | |||
Keydown Problem | Excel Programming | |||
keydown event | Excel Programming | |||
keydown event | Excel Programming | |||
keydown event | Excel Programming |