#1   Report Post  
Posted to microsoft.public.word.docmanagement
TechWriter TechWriter is offline
external usenet poster
 
Posts: 11
Default Required Text Box

Is there a way to make a field required on a form? e.g., prevent a user from
saving a form if a particular field is left blank and displaying a message
telling the user which field needs to be completed.

Thanks for your help.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Required Text Box

Hi TechWriter,

A macro could be used to do this but, if the user's security settings are too high, or the users elects to disable macros in the
document, then the macro approach won't work. The following macro, when placed in the document's €˜ThisDocument module, prevents the
document being closed if it contains any formfields that have not been filled in:
Private Sub Document_Close()
Dim aField As FormField
For Each aField In ActiveDocument.FormFields
If Trim(aField.Result) = "" Then
MsgBox "Please complete all the items"
ThisDocument.Reload
Exit Sub
End If
Next aField
End Sub

You can the following version to check a specific formfield by referencing the field's bookmark name (assuming you've set its
properties to create one):
Private Sub Document_Close()
If Trim(ActiveDocument.Bookmarks("BkMrk").Range.Text) = "" Then
MsgBox "Please complete the nominated item."
'ThisDocument.Reload
Exit Sub
End If
End Sub
where 'BkMrk' is the name of the bookmark. Change the message to suit.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"TechWriter" wrote in message ...
Is there a way to make a field required on a form? e.g., prevent a user from
saving a form if a particular field is left blank and displaying a message
telling the user which field needs to be completed.

Thanks for your help.


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Making text fields required Victoria Microsoft Word Help 6 February 14th 08 07:45 AM
How can I specify that a text field be required? JCROMIG MICR PRIME Microsoft Word Help 0 November 29th 06 05:50 PM
Text box as a required field Katushka Microsoft Word Help 4 May 10th 06 05:08 PM
Help required ??? goldenman Microsoft Word Help 0 January 25th 06 12:17 PM
Help required..... kiran Microsoft Word Help 0 September 1st 05 02:10 PM


All times are GMT +1. The time now is 12:14 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"