Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
TechWriter TechWriter is offline
external usenet poster
 
Posts: 11
Default Required Fields in Word Forms

How do I make text boxes required fields in a Word form? e.g., Require a user
to complete a particular field and display a notification message when the
user tries to save the message without completing the required field.

Thank you for your help.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Required Fields in Word Forms

See http://www.gmayor.com/formfieldmacros.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



TechWriter wrote:
How do I make text boxes required fields in a Word form? e.g.,
Require a user to complete a particular field and display a
notification message when the user tries to save the message without
completing the required field.

Thank you for your help.



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
TechWriter TechWriter is offline
external usenet poster
 
Posts: 11
Default Required Fields in Word Forms

Thanks Graham.

This code prompts the user on exit from the field. Is there a way to prompt
the user to complete any required field when closing the form and prevent the
user from closing the form without completing the required field?

Thanks in advance.

"TechWriter" wrote:

How do I make text boxes required fields in a Word form? e.g., Require a user
to complete a particular field and display a notification message when the
user tries to save the message without completing the required field.

Thank you for your help.

  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Required Fields in Word Forms

If the user is closing the form, what difference does it make whether the
form is completed or not?
You could for example intercept the save command with the following macro in
the same template module -

Public Sub FileSave()
Dim orng As Word.Range
Dim ofld As FormFields

Set orng = ActiveDocument.Range
Set ofld = orng.FormFields

For i = 1 To ofld.Count
ofld(i).Select
If ofld(i).Result = "" Then
MsgBox "All fields must be completed"
Exit Sub
End If
Next i
ActiveDocument.Save
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



TechWriter wrote:
Thanks Graham.

This code prompts the user on exit from the field. Is there a way to
prompt the user to complete any required field when closing the form
and prevent the user from closing the form without completing the
required field?

Thanks in advance.

"TechWriter" wrote:

How do I make text boxes required fields in a Word form? e.g.,
Require a user to complete a particular field and display a
notification message when the user tries to save the message without
completing the required field.

Thank you for your help.



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
TechWriter TechWriter is offline
external usenet poster
 
Posts: 11
Default Required Fields in Word Forms

Thanks again Graham.

The code below works if all of the fields on the form are required. However,
on my form, only some of the fields are required. How do I specify in the
code that the alert message should appear only if the required fields are not
completed? I used this OnEntry and OnExit modules you sent me earlier for the
required fields.

In addition, how do I set the focus back to a particular required field
after the user has tabbed out of the field without entering a value?

Thanks in advance.


"Graham Mayor" wrote:

If the user is closing the form, what difference does it make whether the
form is completed or not?
You could for example intercept the save command with the following macro in
the same template module -

Public Sub FileSave()
Dim orng As Word.Range
Dim ofld As FormFields

Set orng = ActiveDocument.Range
Set ofld = orng.FormFields

For i = 1 To ofld.Count
ofld(i).Select
If ofld(i).Result = "" Then
MsgBox "All fields must be completed"
Exit Sub
End If
Next i
ActiveDocument.Save
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



TechWriter wrote:
Thanks Graham.

This code prompts the user on exit from the field. Is there a way to
prompt the user to complete any required field when closing the form
and prevent the user from closing the form without completing the
required field?

Thanks in advance.

"TechWriter" wrote:

How do I make text boxes required fields in a Word form? e.g.,
Require a user to complete a particular field and display a
notification message when the user tries to save the message without
completing the required field.

Thank you for your help.






  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Required Fields in Word Forms

The on-entry/exit macros return the focus to the uncompleted field. If you
add the entry macros to all the fields (use the macro on the web page to do
that) you will not be able to tab out of the uncompleted field. You need
only put the exit macro on fields that must be completed.

The save macro was merely a fail safe for the occasion when a user clicked
save without visiting a required and thus uncompleted field. However it can
be restricted to the required fields only - Repeat the marked section for
each required field. The macro should select that field selected when run
and will not let you save until all the required fields are filled.

Dim orng As Word.Range
Dim ofld As FormFields

Set orng = ActiveDocument.Range
Set ofld = orng.FormFields
For i = 1 To ofld.Count
ofld(i).Select
'*****************************************
If ofld(i).name = "Text1" Then
If ofld(i).Result = "" Then
MsgBox ofld(i).name & " must be completed"
Exit Sub
End If
End If
'*****************************************
If ofld(i).name = "Text3" Then
If ofld(i).Result = "" Then
MsgBox ofld(i).name & " must be completed"
Exit Sub
End If
End If
Next i
ActiveDocument.Save
End Sub

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



TechWriter wrote:
Thanks again Graham.

The code below works if all of the fields on the form are required.
However, on my form, only some of the fields are required. How do I
specify in the code that the alert message should appear only if the
required fields are not completed? I used this OnEntry and OnExit
modules you sent me earlier for the required fields.

In addition, how do I set the focus back to a particular required
field after the user has tabbed out of the field without entering a
value?

Thanks in advance.


"Graham Mayor" wrote:

If the user is closing the form, what difference does it make
whether the form is completed or not?
You could for example intercept the save command with the following
macro in the same template module -

Public Sub FileSave()
Dim orng As Word.Range
Dim ofld As FormFields

Set orng = ActiveDocument.Range
Set ofld = orng.FormFields

For i = 1 To ofld.Count
ofld(i).Select
If ofld(i).Result = "" Then
MsgBox "All fields must be completed"
Exit Sub
End If
Next i
ActiveDocument.Save
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



TechWriter wrote:
Thanks Graham.

This code prompts the user on exit from the field. Is there a way to
prompt the user to complete any required field when closing the form
and prevent the user from closing the form without completing the
required field?

Thanks in advance.

"TechWriter" wrote:

How do I make text boxes required fields in a Word form? e.g.,
Require a user to complete a particular field and display a
notification message when the user tries to save the message
without completing the required field.

Thank you for your help.



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Required Fields in Word Forms

You might see http://word.mvps.org/FAQs/TblsFldsFm...ateFFields.htm

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

"TechWriter" wrote in message
...
How do I make text boxes required fields in a Word form? e.g., Require a
user
to complete a particular field and display a notification message when the
user tries to save the message without completing the required field.

Thank you 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 08:45 AM
Create expansion fields for word forms MP73 Microsoft Word Help 1 December 27th 06 06:12 PM
Pop-up on 'save' about required form fields Emily Sue Tables 4 November 10th 06 09:44 PM
Required form fields HEllison Microsoft Word Help 1 June 13th 06 07:49 PM
Word forms-req'd fields suelo Microsoft Word Help 1 May 18th 06 05:18 PM


All times are GMT +1. The time now is 08:51 PM.

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"