PDA

View Full Version : Move automatically between Textfields



keyvan
09-12-2007, 06:03 PM
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

OTWarrior
09-13-2007, 12:48 AM
Try this (set it as the "on exit" macro):

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


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

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