Function UndoTable() As Integer
'===============================================================================
'-函数名称: UndoTable
'-功能描述: 恢复删除的数据库对象
'-输入参数说明:
'-返回参数说明: Integer 恢复数据库的个数
'-使用语法示例: MsgBox UndoTable()
'-参考: Access中国论坛帖子
'-使用注意:
'-兼容性: 2000,XP,2003
'-作者: fan0217@163.com
'-更新日期: 2006-03-17
'===============================================================================
'On Error GoTo Err_UndoTable
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
Dim strTemName As String
Dim i As Integer
Set conn = CurrentProject.Connection
strSQL = "Select * FROM MSysObjects "
strSQL = strSQL & "Where(Left$([Name], 1) = '~') And (Left$([Name], 4) <> 'Msys') And (MSysObjects.Type) = 1 "
rs.Open strSQL, conn, 1, 3
Do While Not rs.EOF
strTemName = Right(rs("Name"), Len(rs("Name")) - 4)
strSQL = "Select * INTO [Undo_" & strTemName & "] FROM [" & rs("Name") & "];"
'conn.Execute strSQL
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
i = i + 1
rs.MoveNext
Loop
UndoTable = i
rs.Close
Set rs = Nothing
Set conn = Nothing
Exit_UndoTable:
Exit Function
Err_UndoTable:
Set rs = Nothing
Set conn = Nothing
MsgBox Err.Description
Resume Exit_UndoTable
End Function