Friday, March 07, 2008

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

今個遇到了個電腦的問題,就是在access中的「AO Index 不是這資料表中的索引」真的是滿衰的說,後來也有解決了

救助: "AO Index" 不是這資料表中的索引 (Access)(頁 1) - 軟硬體 - PDA User Message Board - powered by Discuz! Archiver
just try

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:
    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)", _
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
Set dbBad = Nothing
End Sub


Anonymous said...

See Here

Anonymous said...

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

Lee said...