Consulting

Results 1 to 2 of 2

Thread: Move automatically between Textfields

  1. #1

    Move automatically between Textfields

    Hi!
    I have 2 textfields in a word dokumnt with name s1 and s2 which can contain 1 char.
    I want when I write in s1 ,automatically s2 becomes selected.

    I hope i have explaind my question well.

    Does anybody know wich vba-code I must use?
    thanks for help
    Kevin

  2. #2
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location
    Try this (set it as the "on exit" macro):

    [vba]Public Sub SUnameChecker()
    If ActiveDocument.FormFields("S1").Result = "" Then
    Exit Sub
    Else
    ActiveDocument.FormFields("S2").Select
    End If
    End Sub
    [/vba]

    Thats the code for selecting the other form field, although you do have to manually leave the field (mouse click elsewhere or the tab key).

    If you want to leave as soon as you type anything, you may need to have a timer event on entry, and end the timer on close. This could be resource hungry depending on your computer however.

    the following code I have seen elsewhere, but have not tested it, but may point you in the right direction

    [vba]Application.OnTime When:=Now + TimeValue("00:00:01"), Name:="s2"[/vba]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •