恢復從 Access 2000、 Access 2002 或 Access 2003 中數(shù)據(jù)庫刪除表的方法_Access數(shù)據(jù)庫教程
推薦:ACCESS的參數(shù)化查詢,附VBSCRIPT(ASP)和C#(ASP.NET)函數(shù)ACCESS的參數(shù)化查詢,附VBSCRIPT(ASP)和C#(ASP.NET)函數(shù)
注意 : 本文示例代碼使用 Microsoft 數(shù)據(jù)訪問對象。 為此代碼才能正常運行, 您必須引用 Microsoft DAO 3.6 對象庫。 可以進行, 單擊 工具 菜單中 VisualBasic 編輯器, 上 引用 并確保選中 Microsoft DAO 3.6 對象庫 復選框。1. 在 MicrosoftAccess 中打開數(shù)據(jù)庫。
2. 在數(shù)據(jù)庫窗口, 單擊下 對象 , 模塊 , 然后單擊 新建 。
3. 鍵入或粘貼以下代碼, 您只有創(chuàng)建模塊中:
復制代碼 代碼如下:hl5o.cn
Function RecoverDeletedTable()
On Error GoTo ExitHere
'*Declarations*
Dim db As DAO.Database
Dim strTableName As String
Dim strSQL As String
Dim intCount As Integer
Dim blnRestored As Boolean
'*Init*
Set db = CurrentDb()
'*Procedure*
For intCount = 0 To db.TableDefs.Count - 1
strTableName = db.TableDefs(intCount).Name
If Left(strTableName, 4) = "~tmp" Then
strSQL = "SELECT DISTINCTROW [" & strTableName & "].* INTO " & Mid(strTableName, 5) & " FROM [" & strTableName & "];"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
MsgBox "A deleted table has been restored, using the name '" & Mid(strTableName, 5) & "'", vbOKOnly, "Restored"
blnRestored = True
End If
Next intCount
If blnRestored = False Then
MsgBox "No recoverable tables found", vbOKOnly
End If
'*EXIT/ERROR*
ExitHere:
DoCmd.SetWarnings True
Set db = Nothing
Exit Function
ErrorHandler:
MsgBox Err.Description
Resume ExitHere
End Function
4. 在 調試 菜單上, 單擊 編譯 數(shù)據(jù)庫名稱 數(shù)據(jù)庫名稱 。
5. 保存為 RecoverTable 模塊。 要測試此函數(shù), 首先創(chuàng)建兩個表, 添加行, 并刪除這兩個表。
6. 在即時窗口, 鍵入以下行, 然后按 ENTER 鍵:
RecoverDeletedTable
分享:access的備注字段限制64Kaccess的備注字段限制64K
相關Access數(shù)據(jù)庫教程:
- Access數(shù)據(jù)庫安全策略之ASP式
- 第N次被ACCESS的關鍵字涮
- Access中用Jet SQL語句刪除表關系
- Access報表打印如何自動分頁
- Access完成累計余額的計算
- 搭建Access為主的Mdb數(shù)據(jù)庫
- 一句sql更新兩個表并可更新對應的字段值具體實現(xiàn)
- MySQL查詢優(yōu)化:連接查詢排序limit(join、order by、limit語句)介紹
- 內網(wǎng)ssh/mysql登錄緩慢的解決方法
- 使用準則進行條件查詢--1.4.從窗體中選擇查詢的條件
- 中文Access2000速成教程--1.1 使用“向導”設計數(shù)據(jù)庫
- 中文Access2000速成教程--1.3 在“設計”視圖中設計表
- 相關鏈接:
復制本頁鏈接| 搜索恢復從 Access 2000、 Access 2002 或 Access 2003 中數(shù)據(jù)庫刪除表的方法
- 教程說明:
Access數(shù)據(jù)庫教程-恢復從 Access 2000、 Access 2002 或 Access 2003 中數(shù)據(jù)庫刪除表的方法
。