Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Key events on user form

I'm trying to capture the keycodes so that the focus will move to a specific
control based on whether the user hits TAB or ENTER, or SHIFT+TAB after
entering data in a given text box on my form. I've been trying to do so from
the Key_Down event of the text box, but am not having much luck. Any help
will be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Key events on user form

Modify this to do tab or enter or shift or whatever you want. Originally
posted by Ron DeBruin, tests for Control key being pressed. If you need help
modifying post.

Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Integer

Const VK_CONTROL As Integer = &H11 'Ctrl


Sub test()
If GetKeyState(VK_CONTROL) < 0 Then Ctrl = True Else Ctrl = False
If Ctrl = True Then
MsgBox "pressed"
Else
MsgBox "Not"
End If
End Sub



'And this in the sheet module

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call test
End Sub


--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Ken Warthen" wrote:

I'm trying to capture the keycodes so that the focus will move to a specific
control based on whether the user hits TAB or ENTER, or SHIFT+TAB after
entering data in a given text box on my form. I've been trying to do so from
the Key_Down event of the text box, but am not having much luck. Any help
will be greatly appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Key events on user form

John,

The controls and keystrokes I'm trying to manipulate are on a user form, not
a spreadsheet. Does this matter? I thought their were internal VBA commands
that could be used to achieve my goal here without having to call an external
user library.

Ken

"John Bundy" wrote:

Modify this to do tab or enter or shift or whatever you want. Originally
posted by Ron DeBruin, tests for Control key being pressed. If you need help
modifying post.

Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Integer

Const VK_CONTROL As Integer = &H11 'Ctrl


Sub test()
If GetKeyState(VK_CONTROL) < 0 Then Ctrl = True Else Ctrl = False
If Ctrl = True Then
MsgBox "pressed"
Else
MsgBox "Not"
End If
End Sub



'And this in the sheet module

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call test
End Sub


--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Ken Warthen" wrote:

I'm trying to capture the keycodes so that the focus will move to a specific
control based on whether the user hits TAB or ENTER, or SHIFT+TAB after
entering data in a given text box on my form. I've been trying to do so from
the Key_Down event of the text box, but am not having much luck. Any help
will be greatly appreciated.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting .NET form to respond to Excel window events [email protected] Excel Programming 1 May 2nd 07 02:25 PM
No events in form displayed from callback routine Josh Sale Excel Programming 2 November 3rd 06 02:29 AM
Disable Form Events From Being Triggered JGeniti Excel Programming 4 October 14th 05 07:48 PM
TurnOff Form Events ? RAFAAJ2000[_2_] Excel Programming 6 May 29th 05 06:55 PM
Prevent user disabling events JP Farrow Excel Programming 1 September 29th 04 04:49 PM


All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"