Gustav Brock
Gustav at cactus.dk
Fri Feb 13 15:59:25 CST 2009
Hi John
DAO is _very_ fast at this. For example:
Set tbl = dbs.CreateTableDef(strTable)
strField = "Id"
Set fld = tbl.CreateField(strField)
fld.Type = dbInteger
fld.Required = True
fld.DefaultValue = "Null"
tbl.Fields.Append fld
strField = "Something"
Set fld = tbl.CreateField(strField)
fld.Type = dbText
fld.Size = 64
fld.Required = True
tbl.Fields.Append fld
Set idx = tbl.CreateIndex("IndexOne")
idx.Primary = True
idx.Unique = True
strField = "Id"
Set fld = idx.CreateField(strField)
idx.Fields.Append fld
tbl.Indexes.Append idx
dbs.TableDefs.Append tbl
/gustav
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Wednesday, February 11, 2009 7:43 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Build tables programatically
For the class lecture it would be handy to be able to build Access
tables programatically. I do not
know how to do this, though the authors of books usually do so.
Does anyone on this list have any code library that would allow me to
create field X with data type
Y, that is a PK etc etc.
Having that, I can build append queries to append specific data into
these tables, but if anyone has
such a thing, code to extract actual data from a table and write the SQL
Statements that would
append that into a specific table would be nice.
IOW (for example) I have an existing state table and an agency table
with a state ID. In order to
minimize the impact on the readers having to go manually create a state
and agency table and
manually input data into those tables, it would be nice to provide code
that builds those two tables
and then populates those tables with a few data elements.
Ideas anyone?
--
John W. Colby
www.ColbyConsulting.com