WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADO DAO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

DAO CreateTableDef


Question:

Working with DAO, I create a table with db.CreateTableDef(). So then how would I actually go about attaching the table to the database?

Answer:

It is pretty similar to ADO, you create the Tablefdef then create the fields, then append to the tables Object/collection...


;   setup constants...
MDBName   = "C:\Temp\Data\db1.mdb"
dbMemo = 12
dbText = 10

;   open access...
accessDB = ObjectOpen("Access.Application")
ADB = accessDB.Application
dbname = MDBName
ADB.OpenCurrentDatabase(dbname)
ADB.Visible = @FALSE
ADB.UserControl = @FALSE

;   set up the ref to tabledefs collection...
db = accessDB.currentdb

; now create a Table with an real Hyperlink Column
tables = db.TableDefs
tbl = db.CreateTableDef("temp")
flds = tbl.Fields
fld = tbl.CreateField("URL",dbText)
flds.Append( fld )
fld = tbl.CreateField("LINK",dbMemo) ; starts as just a memo field
flds.Append( fld )
tables.Append( tbl )

ObjectClose(fld)
ObjectClose(flds)
ObjectClose(tbl)
ObjectClose(tables)
ObjectClose(db)
ObjectClose(ADB)
ObjectClose(accessDB)

Message("Debug", "All Done")

Exit




Article ID:   W16078
File Created: 2004:03:30:15:42:46
Last Updated: 2004:03:30:15:42:46