Hi there again!
I have a userform with many textboxes (105) that currently when I enter one or two numbers and press "Enter" a generic procedure is run via the "KeyDown" event, manipulating the numbers entered. The problem I am having and am not sure how to fix is; if the user mouse clicks on another textbox without hitting "Enter", the focus changes to the new textbox without firing the "KeyDown" event from the previous textbox. Currently I am using a "KeyDown" event only to trigger my procedure.
How can I make better use of the events by picking up both the "EnterDown" and the left mouse click.
Here is a sample of my code:
![]()
Private Sub txtSPa1_KeyDown(ByVal keycode As MSForms.ReturnInteger, ByVal Shift As Integer) If keycode = vbKeyReturn Or keycode = vbKeyTab Then If iiCheck = 1 Then Call change_SpecialHours iiCheck = 0 Call next_SPtextbox iiCheck = 1 End If End Sub Private Sub txtSPa2_KeyDown(ByVal keycode As MSForms.ReturnInteger, ByVal Shift As Integer) If keycode = vbKeyReturn Or keycode = vbKeyTab Then If iiCheck = 1 Then Call change_SpecialHours iiCheck = 0 Call next_SPtextbox iiCheck = 1 End If End Sub Private Sub txtSPa3_KeyDown(ByVal keycode As MSForms.ReturnInteger, ByVal Shift As Integer) If keycode = vbKeyReturn Or keycode = vbKeyTab Then If iiCheck = 1 Then Call change_SpecialHours iiCheck = 0 Call next_SPtextbox iiCheck = 1 End If End Sub Public Sub change_SpecialHours() 'My code here end sub
Thanks Craig











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks