Friday, March 07, 2008

AO Index 不是這資料表中的索引

今個遇到了個電腦的問題,就是在access中的「AO Index 不是這資料表中的索引」真的是滿衰的說,後來也有解決了
分享一下如何解決的方法,這是我在網路上找的,只有藍色的部份是我自已寫的,其他都是來自網路上的,其中都有連出去的部份,可以看看

救助: "AO Index" 不是這資料表中的索引 (Access)(頁 1) - 軟硬體 - PDA User Message Board - powered by Discuz! Archiver
Lego
just try
[url]http://allenbrowne.com/ser-47.html#AOIndexIsNotAnIndex[/url]


Microsoft Access tips: Recovering from corruption

Symptom: "AOIndex is not an index in this table"

Dirk Goldgar (Microsoft Access MVP) traced this problem back to faulty entries in the MSysAccessObjects table. He reports that the problem can be solved by deleting the faulty entries, and creating a valid primary key.

To use his code (at right):

  1. Make a copy of the mdb file while Access is not running.
  2. In another database, paste the function at right into a module.
  3. Open the Immediate Window (Ctrl+G), and enter:
    FixBadAOIndex("C:\MyPath\MyFile.mdb")
    using your database name in the quotes.
1.弄個複製在另個file(當那個mdb不跑時) 2.開另個database,依下面敘完成模組的編寫,並執行該程式 3.重開access即可


Microsoft Access tips: Recovering from corruption
Sub FixBadAOIndex(BadDBPath As String)
' is the path to the corrupt database.
Dim dbBad As DAO.Database
Dim tdf As DAO.TableDef
Dim ix As DAO.Index

Set dbBad = DBEngine.OpenDatabase(BadDBPath)
dbBad.Execute "DELETE FROM MSysAccessObjects " & _
"WHERE ([ID] Is Null) OR ([Data] Is Null)", _
dbFailOnError
Set tdf = dbBad.TableDefs("MSysAccessObjects")
Set ix = tdf.CreateIndex("AOIndex")
With ix
.Fields.Append .CreateField("ID")
.Primary = True
End With
tdf.Indexes.Append ix
Set tdf = Nothing
dbBad.Close
Set dbBad = Nothing
End Sub
把這上面的資料貼入資料庫的「模組」,然後再打開來看「即時運算」的視窗,用「FixBadAOIndex("C:\...\"),"C:\...\"→是你的access放的路徑。

3 comments:

AntiVirus said...

See Here

Anonymous said...

謝謝!剛好碰上 .mdb 損壞的情況!

Lee said...

請問出現"使用者自訂型態尚未定義"這個錯誤訊息?要怎麼處理呢?