1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Word Form - Required Fields

Discussion in 'Business Applications' started by Mr. Manley, Jan 26, 2009.

Thread Status:
Not open for further replies.
Advertisement
  1. Mr. Manley

    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
     
  2. Anne Troy

    Anne Troy

    Joined:
    Feb 14, 1999
    Messages:
    11,746
    First Name:
    Anne
  3. Anne Troy

    Anne Troy

    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.
     
  4. Mr. Manley

    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?
     
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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/794705

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice