You need to compact the database after you delete the history records. This is to keep the database size small. Because normally, Access is not really goto delete all the records but instead just remark as DELETED. So the Compact database procedure for DAO is just like below:
Code:Option Explicit Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Sub Main() Screen.MousePointer = vbHourglass Dim Db As DAO.Database Set Db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\Biblio.mdb", False, False) 'Purge the unused record. Db.Execute "DELETE * FROM [Title Author];" Db.Close Set Db = Nothing DBEngine.CompactDatabase App.Path & "\Biblio.mdb", App.Path & "\Biblio1.mdb", dbLangGeneral 'Delay 3sec for the computer to catch up. Sleep 3000 'Delete the current database If Dir(App.Path & "\Biblio.mdb") <> "" Then Kill App.Path & "\Biblio.mdb" 'Rename the temp databse to the original database name. Name App.Path & "\Biblio1.mdb" As App.Path & "\Biblio.mdb" Screen.MousePointer = vbDefault End Sub




Reply With Quote