Quote:
> Hi all,
> I have a Access97 Table and I want to copy the
> structure to create a new table in the same db.
> I don't want the records stored in it to come too.
checked code (copied from one of my own progs):
Set td = db.CreateTableDef(tName)
For Each f In db.TableDefs(tName).Fields
If (f.Attributes And dbSystemField) = 0 Then
td.Fields.Append td.CreateField(f.Name, f.Type, f.Size)
End If
Next
db.TableDefs.Append td
Quote:
> I also need to set a Primary Key in the new table,
> Does anybody know how?
Add an index to the tabledef.
Unchecked code I'm making up while typing this, so no guarantees:
set ix = td.createindex(name)
set f = ix.createfield(fname) ' Use name of field you want to index on
td.indexes.append ix
I usually do this before appending the tabledef to the db, but IIRC you can
add them later too.