View Single Post
  #3   Report Post  
Amy
 
Posts: n/a
Default

Thank you Greg, that works.

For some reason I was thinking that just formatting the number in the
properties box would work. Guess not!

Thanks for your contributions to this site!

"Greg Maxey" wrote:

Amy,

You can run a macro on exit form the CCNumber field and if the lenght of the
string is less than 19 (16 characters plus format spaces) then display a
message box and reselect the field.

Set the bookmark name of the the credit card number CCNumber and set the
following macro to run on exit:

Sub ValidateCCNumber()
If Len(ActiveDocument.FormFields("CCNumber").Range.Te xt) 19 Then
Application.OnTime When:=Now + TimeValue("00:00:01"),
Name:="GoBacktoCCNumber"
MsgBox "Please enter the full 16 digit number"
Else
'Do nothing
End If
End Sub
Sub GoBacktoCCNumber()
ActiveDocument.Bookmarks("CCNumber").Range.Fields( 1).Result.Select
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Amy wrote:
I have a form field formatted as ####-####-####-#### for a credit card
number. How do I get it to require all 16 digits? If I enter 1234
it will give me 1234--- and keep going.

Thanks. Amy