Prevent non-standard format!!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I got a measurement(measurements are without Unit,mm,cm)

A X B (general format)

eg 10 X 50 , 20 X 5 , 5 X 20

Question: How to prevent the data from being typed into the field and set
our own error message if the format is not like general format?

Thanks in advance

Kennykee
 
kennykee said:
I got a measurement(measurements are without Unit,mm,cm)

A X B (general format)

eg 10 X 50 , 20 X 5 , 5 X 20

Question: How to prevent the data from being typed into the field and set
our own error message if the format is not like general format?

The best solution would be to store this in 6 separate numeric fields.
 
Actually what i want is to prevent user entering measurements that is not in
wanted format (number X number)
if user insert (10 X 20)==>correct but (10mm X 2mm)==>errormessage and stop
the data entries

Any CODES solution?

Thanks advance

Kennykee
 
kennykee said:
Actually what i want is to prevent user entering measurements that is not in
wanted format (number X number)
if user insert (10 X 20)==>correct but (10mm X 2mm)==>errormessage and stop
the data entries

Any CODES solution?

I suppose an Input Mask that automatically embedded the Xs would work, but it's
just a bad way to store the data. A field should have exactly one piece of
information in it not six.

A Coded solution might be complicated. It would be simple to disallow any
character that is not a digit, a space, or an 'X', but that wouldn't prevent an
entry like 1XX3 or X12X.

If I absolutely had to store data like this I would use an InputMask.
 
you can put you expression into array using Split
then check that is has 3 elements
then then that 1 and 3rd is numbers (isnumeric)
check that 2nd is x
then you can display your own message
 
Actually what i want is to prevent user entering measurements that is
not in wanted format (number X number)



Try this as a validation rule:

IS NULL OR
LIKE "[0-9][0-9] X [0-9][0-9]" OR
LIKE "[0-9] X [0-9][0-9]" OR
LIKE "[0-9][0-9] X [0-9]" OR
LIKE "[0-9] X [0-9]"


all on line. This will allow one- or two- digit numbers with an X in the
middle. If you need more complex regular expressions, then you are
probably beyond what a check constraint can do. You can do anything in a
BeforeUpdate event, however, including using the real RegExp object for
very advanced pattern matching. That of course means you have to limit
your users to using the form.

Your best approach may be to use best-you-can-manage with the validation
rule as a fall-back for the proper user-friendly one on the control.

If the format is really vital, I'd move the two numbers into two numeric
fields and do all the formatting in the query.

Hope that helps


Tim F
 
Back
Top