I’m trying to clean a table. At the moment I’m running the following code to clear the data. My question is would it be quicker to go through the records one by one and then delete the record if it meets the criteria. My code is:
Function ClearAllLines()
DoCmd.SetWarnings False
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE SOURCE Like “”*START*””;”
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE SOURCE Like “”*[*]*””;”
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE AMOUNT Like “”*PAGE*””;”
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE AMOUNT Like “”*LEDGER TRANSACTION LISTING REPORT*””;”
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE SOURCE Like “”*NNMLMR04*””;”
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE AMOUNT Like “”*FINANCIAL AMOUNT*””;”
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE SOURCE Like “”*SOURCE*””;”
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE SOURCE Like “”*=*””;”
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE EFF_DATE=””00/00/00″”;”
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE SOURCE Is Null AND AMOUNT Is Null;”
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE SOURCE Not Like “”*ACCOUNT:*”” AND AMOUNT Is Null;”
‘DoCmd.RunSQL “ALTER TABLE ” & tableName & ” ADD COLUMN Account text, BrNo text;”
DoCmd.RunSQL “UPDATE ” & tableName & ” SET Account = Right([source],3) & Left([jnl_desc],3)WHERE SOURCE Like “”*Account*””;”
DoCmd.RunSQL “DELETE * FROM ” & tableName & ” WHERE SOURCE Like “”*Account:*””;”
DoCmd.RunSQL “UPDATE ” & tableName & ” SET BrNo = [jNL_DESC] WHERE Right([Account],6)=Mid([source],3,6);”
DoCmd.SetWarnings True
End Function
At the moment it takes quite a while to access the table (Records = 3.5Mil) Any help would be appreciated
Thanks