我有一个拆分数据库。尝试使用前端,我可以使用VBA向链接后端的表中添加字段,直到我用密码加密后端。
是否仍然可以使用前端的VBA向后端的表添加字段而不用手动解密后端?
感谢您的回复。
答案 0 :(得分:1)
应该是。试试这些笔记:
Sub AlterDB()
Dim db As DAO.Database
Dim sDB As String
Dim tdf As TableDef
Dim fld As Field
''Encrypted
sDB = "Z:\Docs\Test.enc"
''http://msdn.microsoft.com/en-us/library/office/ff193474.aspx
''Password is case sensitive
Set db = OpenDatabase(sDB, False, False, "MS Access;PWD=pW")
''Option with tabledef
''The table is currently closed
Set tdf = db.TableDefs("table1")
Set fld = tdf.CreateField("NewField", dbText, 20)
tdf.Fields.Append fld
''Option with DDL
ssql = "ALTER TABLE table1 ADD COLUMN AnotherNew Int"
db.Execute ssql, dbFailOnError
End Sub
Sub ListFields()
sDB = "Z:\Docs\Test.enc"
Set db = OpenDatabase(sDB, False, False, "MS Access;PWD=FB")
Set tdf = db.TableDefs("table1")
For Each f In tdf.Fields
Debug.Print f.Name
Next
End Sub