PDA

Click to See Complete Forum and Search --> : Enter Key ( Key Press )


alwsid
Sep 6th, 2000, 10:54 PM
Hi...

How to move cursor using Enter Key ( Key Press )from field to field.

Shafee
Sep 7th, 2000, 01:49 AM
'Try this code
'Assuming that you have an array of text boxes named txtCtl

Sub txtCtl_Keypress(Index as Integer, KeyAscii as Integer)
If KeyAscii = 13 And Index < txtCtl.Count - 1 Then
txtCtl(Index + 1).SetFocus
End If
End Sub

alwsid
Sep 7th, 2000, 03:39 AM
Thanks for your response...

And how if i've an array Text Box and Combo Box.

Shafee
Sep 7th, 2000, 05:41 AM
Try this:

-------------------------------------------------

Sub ChangeFocus(KeyAscii as Integer)
If KeyAscii = 13 Then SendKeys "{TAB}"
End Sub

-------------------------------------------------

You can use the ChangeFocus sub procedure by calling it from the KeyPress event of any control. You have to pass KeyAscii to this procedure.

For example:

-------------------------------------------------

Sub txtEmployeeId_KeyPress(KeyAscii As Integer)

ChangeFocus KeyAscii

End Sub

-------------------------------------------------