Results 1 to 4 of 4

Thread: Forms (2002)

  1. #1
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    Toronto, Canada
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Forms (2002)

    I have a word Form that I will soon post to the internet. There are a list of fields that have to be filled in. Is there a way in Word to make sure each field has something in it?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Form Validation (2002)

    Will people be interacting with your form in Word or will it be converted to HTML and be submitted through the browser?

    In Word, you can write macros that run when a user leaves a field or enters the next one. So, for example, the macro could check to see if the field had any "result" and, if the field is blank, force the user to go back. This wouldn't necessarily prevent someone from printing, saving, or closing the document without filling in the fields; for that you would need to intercept Word's usual behavior at various point to check the fields. If you wanted to really lock it down tight, it could be a big project.

    In HTML, you would write JavaScript or VBScript code to validate the field entries.

  3. #3
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    Toronto, Canada
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Validation (2002)

    Do you know the coding for create the macro that will search each field when leaving?
    Also the form will be posted as HTML later.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Form Validation (2002)

    Well, in April 2002, there was a long thread, but... I can't find it right now.

    Here's what I suggest. Let's suppose you have two textbox fields, Text1 and Text2. Create this macro:

    Sub Text1GoBack()
    'This runs when the user enters Text2
    With ActiveDocument.FormFields("Text1")
    If Len(Trim(.Result)) = 0 Then
    MsgBox "Please enter blah blah blah information before proceeding"
    .Select 'return user to Text1
    End If
    End With
    End Sub

    Then, in the properties for Text2, make Text1GoBack the On Entry macro. When the user enters Text2, the macro will check whether the user put anything (other than empty space) in Text1. If not, the user will see the message and be returned to Text1.

    Repeat as needed for other fields. You also could simply check all the fields when the user tries to Submit or Save or whatever, rather than requiring that they be entered in order. It depends on your needs.

    There must be lots of ways to do this, but try this one to get the idea. As for the HTML, none of this converts to HTML, it will have to be completely re-coded.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •