|
给你一个新建数据库的例子:Dim appAccess As Access.ApplicationSub NewAccessDatabase()
Dim dbs As Object, tdf As Object, fld As Variant
Dim strDB As String
Const DB_Text As Long = 10
Const FldLen As Integer = 40
'新建数据库的名称(更换为你想要的名字)
strDB = "C:\My Documents\Newdb.mdb"
'建立Access程序对象
Set appAccess = CreateObject("Access.Application")
'新建数据库
appAccess.NewCurrentDatabase strDB
Set dbs = appAccess.CurrentDb
'新建表格
Set tdf = dbs.CreateTableDef("Contacts")
Set fld = tdf.CreateField("CompanyName", DB_Text, FldLen)
tdf.Fields.Append fld
dbs.TableDefs.Append tdf
Set appAccess = Nothing
End Sub动态链接数据库可搜索论坛中“链接”的例子;[em04] |
|