John said:
Hi
How can I via code create a table, add a field of type txt(255) and add a
record into it?
There are several ways to do it. You can do it by executing SQL statements,
or by manipulating DAO objects or (I think) ADOX objects. Here's a very
simple example using SQL:
With CurrentDb
.Execute _
"CREATE TABLE MyNewTable (Field1 TEXT(255))", _
dbFailOnError
.Execute _
"INSERT INTO MyNewTable (Field1) " & _
"VALUES('text for field1')", _
dbFailOnError
End With
There are some other options you can apply in the CREATE TABLE statement --
e.g., NOT NULL, or WITH COMPRESSION, or CONSTRAINT -- so the above is just a
simple example.
If you use DAO objects instead, you have finer control over some of the
table and field properties, but it's more complicated.