Peter
I have now had the opportunity to play around with the code you posted, but
following your instructions, I cannot get it work for me. Whether or not the
first formfield has content, the cursor always returns to that field.
Of the three batches of code, only the original one, which calls the
bookmarked fields by name responds correctly, thus the following works for
the same three fields Text1-3. Unfortunately this means you have to
duplicate the code for each field, which produces a lot of code for a form
with lots of fields, and plenty of opportunities to screw up the field names
when anything more complicated than Text1-3 is desired, hence the desire to
simplify it. Your own code also requires separate (albeit shorter) onexit
macros for each field.
I have changed the messages to use MsgBox rather than the help assistant for
the sake of clarity. Any further insights you have would be appreciated.
Sub ExitText1()
With ActiveDocument.FormFields("Text1")
If Len(.Result) = 0 Then
Beep
Application.OnTime When:=Now + TimeValue("00:00:01"),
Name:="GotoText1"
MsgBox ("Field must be completed")
End If
End With
End Sub
Sub ExitText2()
With ActiveDocument.FormFields("Text2")
If Len(.Result) = 0 Then
Beep
Application.OnTime When:=Now + TimeValue("00:00:01"),
Name:="GotoText2"
MsgBox ("Field must be completed")
End If
End With
End Sub
Sub ExitText3()
With ActiveDocument.FormFields("Text3")
If Len(.Result) = 0 Then
Beep
Application.OnTime When:=Now + TimeValue("00:00:01"),
Name:="GotoText3"
MsgBox ("Field must be completed")
End If
End With
End Sub
Sub GotoText1()
ActiveDocument.Bookmarks("Text1").Range.Fields(1).Result.Select
End Sub
Sub GotoText2()
ActiveDocument.Bookmarks("Text2").Range.Fields(1).Result.Select
End Sub
Sub GotoText3()
ActiveDocument.Bookmarks("Text3").Range.Fields(1).Result.Select
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
Web site
www.gmayor.com
Word MVP web site
www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>