|
7#
楼主 |
发表于 2013-12-31 11:48:42
|
只看该作者
以下代码测试可以删除自身数据库的表,查询。请问窗体,报表,宏,模块的删除代码如何写?
Dim tdf As dao.TableDef
Dim qrydf As dao.QueryDef
Dim dbs As dao.Database
Set dbs = CurrentDb
'删除数据表
For Each tdf In dbs.TableDefs
If Left(tdf.Name, 1) = "t" Then
DoCmd.DeleteObject acTable, tdf.Name
ElseIf Left(tdf.Name, 3) = "P" Then
DoCmd.DeleteObject acTable, tdf.Name
ElseIf Left(tdf.Name, 1) = "F" Then
DoCmd.DeleteObject acTable, tdf.Name
ElseIf Left(tdf.Name, 1) = "L" Then
DoCmd.DeleteObject acTable, tdf.Name
End If
Next tdf
'删除查询
For Each qrydf In dbs.QueryDefs
If Left(qrydf.Name, 1) = "Q" Then
DoCmd.DeleteObject acQuery, qrydf.Name
End If
Next qrydf
|
|