Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create tables

Status
Not open for further replies.

cchen

Programmer
Oct 22, 2002
17
US
How to run a script like the following to create tables? Thanks.


' Starting Access Basic DAO Session...

Dim ERwinWorkspace As Workspace
Dim ERwinDatabase As Database
Dim ERwinTableDef As TableDef
Dim ERwinQueryDef As QueryDef
Dim ERwinIndex As Index
Dim ERwinField As Field
Dim ERwinRelation As Relation

Set ERwinWorkspace = DBEngine.WorkSpaces(0)

Set ERwinDatabase = ERwinWorkspace.OpenDatabase(sERwinDatabase)

' CREATE TABLE "CUSTOMER"
Set ERwinTableDef = ERwinDatabase.CreateTableDef("CUSTOMER")
Set ERwinField = ERwinTableDef.CreateField("cust_id", DB_LONG)
ERwinField.Attributes = ERwinField.Attributes + DB_AUTOINCRFIELD
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("cust_buss_name", DB_TEXT, 20)
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("cust_first_name", DB_TEXT, 20)
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("cust_last_name", DB_TEXT, 20)
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("cust_addr", DB_TEXT, 30)
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("cust_city", DB_TEXT, 20)
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("cust_state", DB_TEXT, 2)
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("cust_zip", DB_INTEGER)
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("cust_tel", DB_INTEGER)
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("cust_fax", DB_INTEGER)
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("cust_mobil", DB_INTEGER)
ERwinTableDef.Fields.Append ERwinField
Set ERwinField = ERwinTableDef.CreateField("cust_email", DB_TEXT, 40)
ERwinTableDef.Fields.Append ERwinField
ERwinDatabase.TableDefs.Append ERwinTableDef

ERwinDatabase.Close
ERwinWorkspace.Close
' Terminating Access Basic DAO Session...
 
cchen,

Paste that code in an access module and hit the F5 key. That will run it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top