Dim tbl As DAO.TableDef
If CurrentDb.Properties("StartupShowDBWindow") = False Then
Set tbl = CurrentDb.CreateTableDef("")
tbl.C & Left(Date, 4) & ";DATABASE=大利"
tbl.Attributes = dbAttachSavePWD
tbl.Name = "AAA"
tbl.SourceTableName = "AAA"
CurrentDataBase.TableDefs.Append tbl
CurrentDataBase.TableDefs.Delete "AAA"
End If
我从其它数据库导入运行后。
If CurrentDb.Properties("StartupShowDBWindow") = False Then,说找不到属性!
CurrentDataBase.TableDefs.Append tbl ,说未定义属性
代码增加:
on error resume next
Dim tbl As DAO.TableDef
If CurrentDb.Properties("StartupShowDBWindow") = False Then
Set tbl = CurrentDb.CreateTableDef("")
tbl.C & Left(Date, 4) & ";DATABASE=大利"
tbl.Attributes = dbAttachSavePWD
tbl.Name = "AAA"
tbl.SourceTableName = "AAA"
CurrentDataBase.TableDefs.Append tbl
CurrentDataBase.TableDefs.Delete "AAA"
End If