Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

【access小品】删除数据库中各表记录

时 间:2010-06-14 21:55:32
作 者:todaynew   ID:10802  城市:武汉
摘 要:删除表记录
正 文:

Public Function Deltb(ParamArray tbname() As Variant)
'功能:删除数据库中各表的记录
'参数:tbname---不删除记录的表名称数组
'示例:Call Deltb("物资表","人员表","部门表")
Dim rs As New ADODB.Recordset
Dim ssql As String
Dim i As Long, j As Long
Dim B As Boolean
ssql = "Select Name FROM MSysObjects Where (Type=1 or Type=6) And Not (Name Like 'MSys*' or Name Like '~*')"
rs.Open ssql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
For i = 1 To rs.RecordCount
        B = False
        For j = 0 To UBound(tbname, 1)
              If rs![Name].Value = tbname(j) Then
                   B = True
                   Exit For
              End If
        Next
        If B = False And InStr(rs![Name].Value, "MSys") = 0 Then
              CurrentDb.Execute "Delete * FROM " & rs![Name].Value
        End If
        rs.MoveNext
Next
rs.Close
End Function



Access软件网QQ交流群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助