Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jul 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fields in Word 97

    I have been asked to design a form for users where a telephone number must be inserted. The user can't leave until one has been entered. The length and format of number will vary eg
    01256-121212
    0208-861-1111. Will this require VBA . I have never created macros or VBA code. Any help or suggestions would be greatly appreciated.

    TIA
    Maria

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Fields in Word 97

    Unfortunately, if the formatting is to be mixed, and you want to do any validity checking on it, you will have to write some fairly complex VBA. I'm not a Word Form guru by any stretch, but I think you may have to use VBA just to ensure that someone fills in the field. Perhaps one of the other loungers with more experience in that area can comment <img src=/S/question.gif border=0 alt=question width=15 height=15>
    Wendell

  3. #3
    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: Fields in Word 97

    One answer is that you could assign an Exit macro to the field and force the user to return to the field until you are satisfied with the number. However, as discussed in <!post=Post #133870,133870>Post #133870<!/post> in a very long thread with teachesms, I wasn't able to find a reliable way to "cancel exit" from a field.

    Another option is to have an Enter macro that pops up a small dialog asking for the phone number, which you can check against the formats you want to allow, before accepting it and placing the value into the field.

    I'm not especially handy with formfields, but there are many here who are. Hopefully you will get a more detailed answer.

  4. #4
    Star Lounger
    Join Date
    Mar 2001
    Location
    St Georges du Bois, Pays de la Loire
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Fields in Word 97

    I would use a userform to fill in the field and use the Close button to look at the field to see if anything has been entered. See how to build a userform here:

    http://www.mvps.org/word/FAQs/Userfo...eAUserForm.htm

    The code below is my version of the close button:

    Private Sub tel_num_close_Click()

    Dim validate(0)

    ' Check for entry in tel num field
    validate(0) = ActiveDocument.FormFields("tel_num").Result

    If validate(0) = "" Then

    MsgBox "You must enter a number"

    End If

    If validate(0) <> "" Then

    End

    End If

    End Sub

    It's not foolproof but it works.

    David

Posting Permissions

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