DoCmd.DeleteObject acTable, "表名",如果是連接表,并不能“刪除外數(shù)據(jù)庫mdb的所有表或一個表”。
不妨調(diào)用下面的子過程試試:
Sub sbDeleteAllTables()
Dim db As Database
Dim td As TableDef
Set db = OpenDatabase("D:\Documents and Settings\GGLDD\My Documents\db1.mdb")
For Each td In db.TableDefs
If (td.Attributes And dbSystemObject) = 0 Then '不可刪除系統(tǒng)表
db.Execute "Drop TABLE " & td.Name & ";"
End If
Next
db.TableDefs.Refresh
Set td = Nothing
Set db = Nothing
End Sub
不妨調(diào)用下面的子過程試試:
Sub sbDeleteAllTables()
Dim db As Database
Dim td As TableDef
Set db = OpenDatabase("D:\Documents and Settings\GGLDD\My Documents\db1.mdb")
For Each td In db.TableDefs
If (td.Attributes And dbSystemObject) = 0 Then '不可刪除系統(tǒng)表
db.Execute "Drop TABLE " & td.Name & ";"
End If
Next
db.TableDefs.Refresh
Set td = Nothing
Set db = Nothing
End Sub