Re: ADOX in vb6 and access97




"Ralph" <nt_consulting64@xxxxxxxxx> wrote in message
news:u8J80yFsIHA.5872@xxxxxxxxxxxxxxxxxxxxxxx


Dim db As DAO.Database
Dim tdf As



Oops! Hit the wrong key...

It using DAO (3.6) this is rather straightforward.

Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim idx As DAO.Index

Set db = currentdb()
' create TableDef
Set tdf = db.CreateTableDef("MyTable")
' add field to table definition
' a name, a type, and a size
Set fld = tdf.CreateField("Description", dbText, 25)
tdf.Fields.Append fld
' add more more fields ...
' then append the flds
db.TableDefs.Append tdf
'...
' To set additional parameters mess with the 'Index'
Set idx = tdf.CreateIndex("Primary Key")
Set fld = idx.CreateField("Description")
idx.Primary = True
idx.Unique = True
idx.Fields.Append fld
' add index to Indexes collection
idf.Indexes.Append idx
' ...
' other properties.
idx.IgnoreNulls = False
idx.Required = True

Intellisense is your friend. <g>

You can play with re-setting these properties on existing Fields, but
remember you can often run into problems when you go to update the table.
For example, setting the property to "allow no duplicates" may either error
or actually delete records.
I find it safer to make a new field, copy the data, then delete the
original.

hth
-ralph


.