Klatuu said:
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.
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.