The original poster stated that it was a 'first name' field, Jamie.
Therefore in my opinion it is not a question of what characters are or are
not allowed, but of what characters can or can not appear in a person's
given name. If the person in question is someone important to your
organisation (like a customer) do you want to be the one to explain that
his/her name is 'not allowed'? Hopefully, the days when we tolerated
applications that could not correctly record our names are past, or at least
passing, along with the technical limitations that formerly excused the
practise.
You do raise some interesting points, however, and you are absolutely
correct about the missing trailing space.
--
Brendan Reynolds (MVP)
Brendan said:
This will disallow perfectly valid characters such as à, á, â, ã, ä, å, etc.
There is, after all, a *reason* why Jet uses Unicode.
Those characters are ASCII, not Unicode! AFAIK the reason Jet datatypes
were converted to Unicode is to support other languages e.g. Chinese
characters spring to mind, here.
... and any entry that does not contain exactly 10 characters ...
Public Sub TestIt()
Dim strSQL As String
strSQL = "CREATE TABLE Test ( data_col VARCHAR(10) NOT NULL, " & _
"CHECK(data_col & Space$(10 - Len(data_col)) LIKE " & _
"'[A-Z ][A-Z ][A-Z ][A-Z ][A-Z ][A-Z ][A-Z ][A-Z ][A-Z ][A-Z]'));"
CurrentProject.Connection.Execute strSQL
End Sub
Thanks for posting your code because I spotted that the trailing space
is missing from the last pattern matching character i.e. you have [A-Z]
rather than [A-Z ]. The word wrap is to blame here, no doubt.
And who said those accented etc characters were allowed, anyhow? My
rule certainly doesn't <g>. I take your point, though, and I can
incorporate more characters if desired e.g. (beware of the wrap):
CREATE TABLE Test (
data_col VARCHAR(10) NOT NULL,
CHECK(data_col & Space$(10 - Len(data_col)) LIKE
'[A-ZÀ-ÿ ][A-ZÀ-ÿ ][A-ZÀ-ÿ ][A-ZÀ-ÿ ][A-ZÀ-ÿ ][A-ZÀ-ÿ
][A-ZÀ-ÿ ][A-ZÀ-ÿ ][A-ZÀ-ÿ ][A-ZÀ-ÿ ]')
);
This could get quite lengthy, of course, but I still think it's easier
to state what is allowable rather than try to exclude all those Chinese
characters, Japanese characters, etc.
Jamie.
--