vbams-accesserror-handlinglow-memory

MS Access VBA: how to trap case where delete hangs due to low memory or disk space?


I have a sporadic error in MS Access 2007 which I can't reliably reproduce. The circumstances are these:

  1. Load 500K+ rows of text data from file into a table
  2. [do stuff with loaded data]
  3. Attempt to delete contents of table from vba with CurrentDB().Execute "Delete * from RawImport", where RawImport is the table name

At step 3, the code will sometimes hang up until I ctrl-Break. When this happens, if Ctrl-F11 back to the database view and attempt to delete the contents of the table, it will always give me an error "there is not enough memory or disk space to complete this action with undo, do you want to continue" (paraphrased, I haven't been able to capture the error)

Exiting Access and reloading will usually clear this so that the VBA code runs, which is all fine and lovely, but how can I trap for this? It doesn't generate an error in the vba at the delete, it just sits there at the line until I break manually.


Solution

  • In the end, I did follow the approach of creating a temporary database, creating the table on the fly in that one, linking it from my main database and then deleting the temporary database at the of each load/process cycle. It works OK, but it's a bit over-complicated for a really simple use-case of the database - not hard to see why people outgrow Access so readily.