• Fields in Word 97

    Author
    Topic
    #373620

    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

    Viewing 2 reply threads
    Author
    Replies
    • #601451

      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 question

    • #601624

      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 #133870 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.

    • #601668

      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/Userforms/CreateAUserForm.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

    Viewing 2 reply threads
    Reply To: Fields in Word 97

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: