Sorry, Brian, but I have to disagree with both of your ideas.
Why carry around a table with nothing more than 00 - 99 in it when a simple
code test will resolve it. The code test is much faster than a database
fetch. I also don't think this has anything to do with database integrity.
As to the field level validation. I never use it. First, you will be right
back to the problem of presenting you own error message. Sure, you can use
the Validation Text, but you don't have the same level of control over what
happens next. And second, should you ever have to upsize the database, I
don't know if there are any that an Access field or table level validation
rule or text can be translated to.
> >I have a textbox that I have set an Input mask of 00;;_ for a two digit
> > station number.
[quoted text clipped - 21 lines]
> These solutions mean that it is impossible to enter unacceptable data,
> whereas writing code can only do it's best to prevent this happening.
stefan hoffmann - 03 Apr 2006 23:22 GMT
hi,
> Sorry, Brian, but I have to disagree with both of your ideas.
> Why carry around a table with nothing more than 00 - 99 in it when a simple
> code test will resolve it. The code test is much faster than a database
> fetch. I also don't think this has anything to do with database integrity.
This is correct, except it is a domain definition, in this case the
RDBMS should take care of this too.
mfG
--> stefan <--
Brian Wilson - 03 Apr 2006 23:50 GMT
> Sorry, Brian, but I have to disagree with both of your ideas.
> Why carry around a table with nothing more than 00 - 99 in it when a
[quoted text clipped - 12 lines]
> don't know if there are any that an Access field or table level validation
> rule or text can be translated to.
Of course all ideas have pros and cons and it is probably good that the OP
sees a range of solutions. However, you seem to have missed the fact that I
was only suggesting creating a related table if 'these codes had meanings
which code be put into words'. So if these were codes for the accounts
department to analyze expenses where "24" was paper, "25" pens and "26"
pencils, etc then it might make sense to have the related table.
Obviously I don't know if that is the case - but the suggestion is there if
this is appropriate.
As to the second suggestion, I personally would prefer the validation rule
to enforcing with a code-only solution. Perhaps you would also set the
length to 255 and try to enforce the maximum length by writing code, but I
would feel safer in knowing that there was a limit of 2 characters specified
in the table definition. In the same way, I feel safer knowing that a rule
of <Like "##"> means that whatever form I add, whatever code I change, I
will not and can not break this rule.
I agree that you may want to catch the error and write your own text rather
than the simple validation text, but at least you can be sure you get the
right data. If the database has only one data-entry form and nobody will
ever enter data in any other way or find another way to screw things up for
you, then you might want to rely on the code-only solution, but at least the
OP has an alternative perspective to consider.