Stop up\down cursor keys moving between fields? 
Author Message
 Stop up\down cursor keys moving between fields?

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.



Fri, 06 Aug 2004 16:55:35 GMT  
 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.



Sat, 07 Aug 2004 00:09:43 GMT  
 Stop up\down cursor keys moving between fields?
Thanks Jay, smashing info (as ever)!

Carl.

Quote:

> 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



>>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.



Sat, 07 Aug 2004 16:52:43 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Repost: Stop up\down cursor keys moving between (text) form fields in a protected document

2. Causing the cursor moves to next tab stop when a field has reached its maximum

3. cursor should not move up or down in MSHFLexgrid

4. Enabling Tab Key to move from field to field

5. Using ENTER key to move from field to field

6. how to create a box that can be moved with cursor keys or mouse

7. Arrow key to move cursor to next textbox???

8. Arrow keys to move cursor to next textbox.

9. How to move cursor on my desired position specifying primary key

10. how can I move the cursor between fields......

11. how can I move the cursor between fields......

12. SET UPS: Please Stop... AND Lood

 

 
Powered by phpBB® Forum Software