Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2005

Tip: Looking for answers? Try searching our database.

Prevent non-standard format!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kennykee - 06 May 2005 02:27 GMT
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
Rick Brandt - 06 May 2005 02:37 GMT
>I got a measurement(measurements are without Unit,mm,cm)
>
[quoted text clipped - 4 lines]
> 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.

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

kennykee - 06 May 2005 02:49 GMT
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

> >I got a measurement(measurements are without Unit,mm,cm)
> >
[quoted text clipped - 6 lines]
>
> The best solution would be to store this in 6 separate numeric fields.
Rick Brandt - 06 May 2005 03:02 GMT
> 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.

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

Tim Ferguson - 06 May 2005 17:40 GMT
> 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
Alex Dybenko - 06 May 2005 06:37 GMT
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

Signature

Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com

>I got a measurement(measurements are without Unit,mm,cm)
>
[quoted text clipped - 8 lines]
>
> Kennykee
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.