Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Input Mask for Fax Numbers (Word 2000)

    Is it possible to create an "input mask" for use with a text box on a VBA userform, so that anything typed into the text box automatically prints in the document in the format of xx-xxx-xxxx? I don't want to split the text box into three different boxes as I am sometimes populating this text box with information from the fax number field in Outlook, or from another database.

    Any ideas would be welcome
    Cheers.

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Input Mask for Fax Numbers (Word 2000)

    > text box automatically prints in the document

    How automatically do you want it?

    If I've understood your requirements, the user can type data (supposedly a fax number) willy-nilly into a text box, but you want to coerce it into a standard format for use in the document, one use being "printed display".

    If so, one of the three events listed below might help, as might a search on VBA for the events "AfterUpdate", "Change" and/or "Exit".

    Depending on how quickly you want to slap the user's wrists. "Change" lets you write code that screams at the first offending character as it is typed. "AfterUpdate" and "Exit" let you wait, skulking maliciously in the wings, until the user has completed 30 minutes of data entry, whereupon you pounce and say "You made a mistake way back here".

    Hope this helps .....


    <pre>Private Sub TextBox1_AfterUpdate()
    End Sub
    Private Sub TextBox1_Change()
    End Sub
    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    End Sub
    </pre>


  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Input Mask for Fax Numbers (Word 2000)

    Did you understand that?

    How about this:


    Private Sub txtFaxNum_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    txtFaxNum.Value = Format(txtFaxNum.Value, "(###) ###-####")
    End Sub
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Input Mask for Fax Numbers (Word 2000)

    Hi Chris, I thought skulking maliciously in the wings was the way to go so have used an on exit event. The form is only small so the user doesn't have to wait long to be screamed at!!

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Input Mask for Fax Numbers (Word 2000)

    This is exactly what I'm after. I actually use Format all the time - but my tunnel vision didn't allow me to contemplate using the textbox value property and formatting that!!

    Thanks!

Posting Permissions

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