The WRONG way to clear a table

I swear, I haven't seen something this stupid in a very long time (and I work with Access everyday).

DoCmd.OpenTable "TblOracleUploadAdjs", acViewNormal, acEdit
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdDelete
DoCmd.Close acTable, "TblOracleUploadAdjs"

For the uninitiated, what this does is open a table up, select all the records, deletes them, then closes the table. The better way to do this would be to execute the following query:

delete from TblOracleUploadAdjs;

Or to fully solve this:

DoCmd.SetWarnings false
DoCmd.RunSQL "delete from TblOracleUploadAdjs"
DoCmd.SetWarnings true

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options