Validation of text fields

G

GaryB

Hi,

I am trying to validate a text field on a form to the NZ IRD number
format (two digits; hyphen; three digits; hyphen; three digits).

The following validation formula

format([IRD Number], ##-###-####)

generates the following syntax error:

-----------------
Error in Validation formula for "IRD Number" -- the Date Constant is
not valid. Make sure you have entered a valid date in the formula.
-----------------

The following validation formula

format([IRD Number], 12-345-678)

validates

--

(two hyphens) as true. I.e. it forces the hyphens, but doesn't force
the correct number of digits.

Where am I going wrong?

Thanks very much.

Rgds

GaryB
 
S

Sue Mosher [MVP-Outlook]

A validation formula must return True if the data is "good" and False if
it's not. Therefore, Format(), which is a text formatting function, does
work as a validation formula. Instead, you would need to perform text
parsing using Mid() and other functions to check whether each of the five
parts of the field meets your criteria. I personally wouldn't try to do that
with a formula -- too hard to debug -- but would use code in the Item_write
or Item_Send event handler instead.
 

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