|
能否将代码注释一下,以便新学者能好理解!
Function UndoTable()
Dim db As DAO.Database, strTablename As String
Dim i As Integer, StrSqlString As String
Dim strTemName As String
Set db = CurrentDb()
For i = 0 To db.TableDefs.Count - 1
If Left(db.TableDefs(i).Name, 4) = "~tmp" Then
strTablename = db.TableDefs(i).Name
strTemName = Right(strTablename, Len(strTablename) - 4)
StrSqlString = "SELECT DISTINCTROW [" & strTablename & _
"].* INTO [" & strTemName & "] FROM [" & strTablename & "];"
DoCmd.SetWarnings False
DoCmd.RunSQL StrSqlString
DoCmd.SetWarnings True
MsgBox strTemName & " Table 已恢复"
End If
Next i
Exit_Undo:
Set db = Nothing
Exit Function
Err_Undo:
MsgBox Err.Description
Resume Exit_Undo
End Function |
|