A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Microsoft Word Help
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Validate form field



 
 
Thread Tools Display Modes
  #1  
Old October 10th 05, 04:48 PM
Amy
external usenet poster
 
Posts: n/a
Default Validate form field

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

Ads
  #2  
Old October 10th 05, 05:38 PM
Greg Maxey
external usenet poster
 
Posts: n/a
Default

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



  #3  
Old October 10th 05, 06:26 PM
Amy
external usenet poster
 
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




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Text form field inside a WORD table cell, odd behavior when select pwrichcreek Tables 9 October 20th 05 12:34 AM
Text form field inside WORD table cell, odd selection behavior pwrichcreek Microsoft Word Help 1 October 11th 05 03:57 PM
Form Field Formatting Leslie Microsoft Word Help 3 June 14th 05 03:06 PM
Enter data in 1 text form field & have multiple locations fill Lee Microsoft Word Help 1 March 16th 05 10:56 PM
Text Form Field Ref in Footer Won't Update on Screen StarWine Microsoft Word Help 3 December 6th 04 06:17 PM


All times are GMT +1. The time now is 10:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright 2004-2020 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.