
Stop up\down cursor keys moving between fields?
Hi, Carl,
You can catch the keystroke with the KeyDown event, like this:
Private Sub TextBox1_KeyDown(ByVal KeyCode As _
MSForms.ReturnInteger, ByVal Shift As Integer)
With TextBox1
Select Case KeyCode
Case vbKeyDown
If .CurLine = .LineCount - 1 Then
KeyCode = 0
Beep ' optional
End If
Case vbKeyUp
If .CurLine = 0 Then
KeyCode = 0
Beep
End If
Case Else
End Select
End With
End Sub
You can add other keys to be handled as other Case clauses. For boxes with other
names, be sure to change both occurrences of "TextBox1" -- one in the procedure
header and one in the With statement.
--
Regards,
Jay Freedman
Microsoft Word MVP Word MVP FAQ site: http://www.mvps.org/word
Quote:
> Hi,
> Can I stop the use of the up\down cursor key press to move between
> fields. If I have a long field (well multiple lines) I would like the
> up\down key press to move between the lines in the field only.
> Thanks
> Carl.