Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

Force Entry in Text Field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jamie - 09 Sep 2005 18:40 GMT
I am working in Word 2002.  I have a check box (check1), that if checked the
user must complete text1.

I would like to have an OnExit macro, so when the user tabs out of text1,
and check1 is checked, a message will appear stating "You must complete this
field."

I'm not sure how to go about doing this, any help is appreciated.

Thanks,

Signature

Jamie

Jay Freedman - 09 Sep 2005 19:16 GMT
>I am working in Word 2002.  I have a check box (check1), that if checked the
>user must complete text1.
[quoted text clipped - 6 lines]
>
>Thanks,

The basic idea is explained at
http://www.word.mvps.org/FAQs/TblsFldsFms/ValidateFFields.htm. The
specific test in the example macro won't do, of course. The code you
need looks something like this:

Sub ExitText1()
   With ActiveDocument.FormFields("Text1")
       If Len(.Result) = 0 And _
               ActiveDocument.FormFields("Check1") _
               .CheckBox.Value = True Then
           Application.OnTime _
               When:=Now + TimeValue("00:00:01"), _
               Name:="GoBacktoText1"
           MsgBox "You must complete this field"
       End If
   End With
End Sub

Sub GoBacktoText1()
   ActiveDocument.Bookmarks("Text1").Range _
       .Fields(1).Result.Select
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Jamie - 09 Sep 2005 22:25 GMT
Hi Jay, thanks for the coding, it's working great!!
Signature

Jamie

> >I am working in Word 2002.  I have a check box (check1), that if checked the
> >user must complete text1.
[quoted text clipped - 34 lines]
> Jay Freedman
> Microsoft Word MVP        FAQ: http://word.mvps.org
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.