Use enter key to move to next field 
Author Message
 Use enter key to move to next field

In VB,
a) Set the Form.KeyPreview property to True
b) Add an event procedure like this to your form:
Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        KeyAscii = 0
        SendKeys "{Tab}"
        Exit Sub
    End If
End Sub

Eric Garza (Not a Fox guy:)


Quote:
> How do you use the keypress event to use Enter key instead of Tab key to
> move to the next field?




Mon, 11 Mar 2002 03:00:00 GMT  
 Use enter key to move to next field
How do you use the keypress event to use Enter key instead of Tab key to
move to the next field?



Tue, 12 Mar 2002 03:00:00 GMT  
 Use enter key to move to next field
Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        KeyAscii = 0
        Text2.setfocus
    End If
End Sub

I never recomend sendkeys they are flakey to say the least

        C.David Johnson
        Missionary searching for a Field
        http://www.siteblock.net

        Do not reply to the posted address it belongs to
        the Federal Trade Commissions Spam enforcement Division
        Visit my site to get the real e-mail.



Tue, 12 Mar 2002 03:00:00 GMT  
 Use enter key to move to next field
If you don't want to use Sendkeys set the active-control enabled = false
and in the next line enabled = true.

So the focus went to next control with the tabstop = true.

example:

two Textfields on a form

Text1.Tabindex=1 and text2.tabindex=2

if the focus is on text1 and you put this code into the keydown or keypress
event of the textfield you'll get the focus on text2:

public sub text1_keydown(keyascii as integer (???))

    if keyascii=vbkeyreturn then
        me.text1.enabled=false
        me.text1.enabled=true
    end if

end sub

best regards
Alex

--

Dim Life as Boolean

Life = True


http://www.crazyALEX.notrix.de

ich wnsche noch nen bug-freien Tag!
i'll wish you a bug-free day!


Quote:
>Private Sub Text1_KeyPress(KeyAscii As Integer)
>    If KeyAscii = 13 Then
>        KeyAscii = 0
>        Text2.setfocus
>    End If
>End Sub

>I never recomend sendkeys they are flakey to say the least

> C.David Johnson
> Missionary searching for a Field
>        http://www.siteblock.net

>        Do not reply to the posted address it belongs to
>        the Federal Trade Commissions Spam enforcement Division
>        Visit my site to get the real e-mail.



Tue, 12 Mar 2002 03:00:00 GMT  
 Use enter key to move to next field
David,

I've been using that technique for over a year since VB5 on many
applications and have had no problems at all.
Could you please elaborate on what the SendKeys problems are for you?

Regards,
Eric Garza



Quote:
> Private Sub Text1_KeyPress(KeyAscii As Integer)
>     If KeyAscii = 13 Then
>         KeyAscii = 0
>         Text2.setfocus
>     End If
> End Sub

> I never recomend sendkeys they are flakey to say the least

> C.David Johnson
> Missionary searching for a Field
>         http://www.siteblock.net

>         Do not reply to the posted address it belongs to
>         the Federal Trade Commissions Spam enforcement Division
>         Visit my site to get the real e-mail.



Tue, 12 Mar 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Using the ENTER key to move to the next field

2. Use enter key to move to next field

3. Make Enter key default move to next field?

4. Using ENTER key to move from field to field

5. How do I get the enter key to automatically tab to the next form field

6. Press Enter key to go to next field

7. Advancing to next form field with Enter key instead of Tab

8. Using Enter Key to Go to Next Box

9. Move Between Fields with "Enter" Key

10. Moving in fileds with Enter-key instead og Tab-key

11. Hit ENTER to move to next control ?

12. How do I move cursor to next textbox after hitting enter

 

 
Powered by phpBB® Forum Software