There is a truly bizarre bug when executing the ALTER TABLE
statement against Access 97 database (basically an .MDB file). Say you
want to create a table with 100 char(255) fields. The help file talks about how the
max length of the record is about 2k (around 1900 bytes,
actually) and this is mentioned in the description for DAO error 3047. One
way to beat this limit is to use ALTER TABLE statement and add
each field individually. Oddly enough, it works. However, you have
to be aware of idiosyncrasy described below.
When you are crossing or after you've crossed the
2k limit, the following code will not work, even though
it is syntactically correct:
Connection.Execute "ALTER TABLE
myTable ADD COLUMN textField20 CHAR(255) NULL;"
This code will work however,
when you are not crossing the 2k limit,
Each of the code lines
below will work in any situation:
Connection.Execute "ALTER TABLE
myTable ADD COLUMN textField20 VARCHAR(255) NULL;"
Connection.Execute "ALTER TABLE
myTable ADD COLUMN textField20 STRING(255) NULL;"
Connection.Execute "ALTER TABLE
myTable ADD COLUMN textField20 ALPHANUMERIC(255) NULL;"
Connection.Execute "ALTER TABLE myTable ADD COLUMN
textField20 CHARACTER(255) NULL;"
This method also works when using CREATE TABLE statement. Basically just avoid usage of CHAR
data type and use its synonyms.
So to
wrap up, CHAR data type works fine in Data Definition Language as long as you
are not crossing the 2k limit.
This whackyness has been tried and confirmed on DAO
3.51, 3.60 and ADO 2.5 with JET OLEDB 4.0 provider.