Incorrect Field Validation

S

Simon Ransom

Hello

I am trying to validtae that a field has a value more than 1. I am using
the following code from the word.mvps.org site. Works correctly for any
numbers 0 through 9 but does not work for 10, 11, 20, 21 etc. Obviously due
to some issue with the number of digits that it is checking but i am not
familiar enough to work it out...
==================
Sub ExitTotalPages()
With ActiveDocument.FormFields("fTotalPages")
If Len(.Result) > 0 And Right$(.Result, 1) < "2" Then
Application.OnTime When:=Now + TimeValue("00:00:01"),
Name:="GoBacktoTotalPages"
MsgBox "Please ensure that you have entered the correct Total
Number of Pages for your Purchase Order, the value of 1 cannot be correct!"
End If
End With
End Sub
============================
Sub GoBacktoTotalPages()
ActiveDocument.Bookmarks("fTotalPages").Range.Fields(1).Result.Select
End Sub
============================
Any input much appreciated

Simon
 
W

Word Heretic

G'day Simon Ransom <[email protected]>,

<Sighs>

Sub ExitTotalPages()
With ActiveDocument.FormFields("fTotalPages")
If Val(.Result) > 1 Then

....

<sobs>

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Simon Ransom reckoned:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top