Word Form - Required Fields

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Mr. Manley

Thread Starter
Joined
Jan 26, 2009
Messages
3
I am trying to create a form with required fields for a document at work. I was able to use code provided by Anne Troy to easily do this. However, I just have one additional question to complete a modification I had. Basically, on certain questions, I want the form to verify that the "Next" field is completed. So that if on question 7a "Yes" is selected from a drop down box, then question 7b must be answered. Here is an excerpt with the IF statements...


For Each fld In ReqFields
If Trim(fld.Result) = "" Then
MsgBox "You must complete " & fld.Range.Bookmarks(1).Name & " before you can print.", vbOKOnly + vbExclamation, "Error"
Cancel = True
fld.Select
Exit Sub
End If
If Trim(fld.Result) = "Select..." Then
MsgBox "You must select an answer for " & fld.Range.Bookmarks(1).Name & " before you can print.", vbOKOnly + vbExclamation, "Error"
Cancel = True
fld.Select
Exit Sub
End If
If Trim(fld.Result) = "Yes" And "NextField" = "" Then
MsgBox "You selected 'Yes' for " & fld.Range.Bookmarks(1).Name & "." & vbNewLine & "Please answer Question 'b' after " & fld.Range.Bookmarks(1).Name & " before printing.", vbOKOnly + vbExclamation, "Error"
Cancel = True
fld.Select
Exit Sub
End If
Next fld
End Sub
 
Joined
Feb 14, 1999
Messages
11,746
First Name
Anne
LOL! I just realized you used code provided by ME?? Yeah, right. I must've stolen it somewhere.
 

Mr. Manley

Thread Starter
Joined
Jan 26, 2009
Messages
3
Thanks, Anne! I actually figured it out with a little trial and error. What I needed was Trim(fld.Next.Result) = ""

I do have another question though... How would I set this up to require fields before doing a "Save As"? My boss loves the form but said our agents will be sending the form to our clients after filling in the answers and sometimes they will save and email the form rather than printing and faxing. I tried changing wordApp_DocumentBeforePrint as wordApp_DocumentBeforeSaveAs, but it didn't work. Any suggestions?
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top