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