我是这样做的,数据库与表我都是系统自动生成的
rf2 = RFSO.FileExists(App.Path + "\Ren\DH\DH.mdb")
If Not rf2 Then
Set db = DBEngine.CreateDatabase(App.Path + "\Ren\DH\DH.mdb", dbLangGeneral)
db.NewPassword "", "19830829"
Set td = New TableDef
'---------------------------------------------添加线位
Set f = td.CreateField("XW", dbText, 12)
td.Fields.Append f
'---------------------------------------------添加电话号码A
Set f = td.CreateField("DHHM", dbText, 12)
td.Fields.Append f
'---------------------------------------------添加用户名称A
Set f = td.CreateField("YHMC", dbText, 60)
td.Fields.Append f
'---------------------------------------------添加用户种类A
Set f = td.CreateField("YHZL", dbText, 20)
td.Fields.Append f
'---------------------------------------------添加身份证号码A
Set f = td.CreateField("SFZHM", dbText, 30)
td.Fields.Append f
'---------------------------------------------添加装机地址A
Set f = td.CreateField("ZJDZ", dbText, 150)
td.Fields.Append f
'---------------------------------------------添加联系人A
Set f = td.CreateField("LXR", dbText, 12)
td.Fields.Append f
'---------------------------------------------添加联系电话A
Set f = td.CreateField("LXDH", dbText, 12)
td.Fields.Append f
'---------------------------------------------添加装机日期A
Set f = td.CreateField("ZJRQ", dbText, 12)
td.Fields.Append f
'---------------------------------------------添加装机人A
Set f = td.CreateField("ZJR", dbText, 12)
td.Fields.Append f
'---------------------------------------------添加宽带账号
Set f = td.CreateField("KDZH", dbText, 30)
td.Fields.Append f
'---------------------------------------------添加线位
Set f = td.CreateField("JFXW", dbText, 30)
td.Fields.Append f
'---------------------------------------------添加后列
Set f = td.CreateField("JFHL", dbText, 30)
td.Fields.Append f
'---------------------------------------------添加机房转跳
Set f = td.CreateField("JFZT", dbText, 30)
td.Fields.Append f
'---------------------------------------------添加宽带线位
Set f = td.CreateField("KDXW", dbText, 30)
td.Fields.Append f
'---------------------------------------------添加交线1
Set f = td.CreateField("JX1", dbText, 30)
td.Fields.Append f
'---------------------------------------------添加交线2
Set f = td.CreateField("JX2", dbText, 30)
td.Fields.Append f
'---------------------------------------------添加交线3
Set f = td.CreateField("JX3", dbText, 30)
td.Fields.Append f
'---------------------------------------------添加交线4
Set f = td.CreateField("JX4", dbText, 30)
td.Fields.Append f
'---------------------------------------------物理位置
Set f = td.CreateField("WLWZ", dbText, 15)
td.Fields.Append f
'---------------------------------------------代号
Set f = td.CreateField("NO1", dbText, 5)
td.Fields.Append f
td.Name = "DH"
db.TableDefs.Append td
Set db = Nothing
End If