MEMORY ERROR When Running Code

  • Thread starter Thread starter John
  • Start date Start date
J

John

I am trying to run in code, a series of delete queries,
append queries and printing reports. After it gets to the
last part of the code, it give me a memory error message
and then kicks me out of Access.

If I run the queries manually one after the other, I do
not get a memory error message.

Am I doing something wrong in my code to cause this
error?

THANKS IN ADVANCE!!!

Here is my code:
Dim stdocName1 As String
Dim stdocName2 As String
Dim stdocname3 As String
Dim stdocname4 As String
Dim stdocname5 As String
Dim stDocName6 As String
Dim stDocName7 As String

Need to clear out tbltoolwatchbad, tbltoolwatchvalidate
and tbltoolwatchexport tables
stdocName1 = "DeltblToolWatchBad"
DoCmd.OpenQuery stdocName1, acNormal, acEdit

stdocName2 = "DeltblToolWatchValidate"
DoCmd.OpenQuery stdocName2, acNormal, acEdit

stdocname3 = "DeltblToolWatchExport"
DoCmd.OpenQuery stdocname3, acNormal, acEdit

'Append new tool records to tblToolWatchexport Table
stdocname4 = "AppNewToolRecords"
DoCmd.OpenQuery stdocname4, acNormal, acEdit


'Append new transfer records to tblToolWatchValidate table
'These records need to be validated
stdocname5 = "AppNewTransferRecords"
DoCmd.OpenQuery stdocname5, acNormal, acEdit

'Print outs of "Special Records" and "Jobs Not Open"

stDocName6 = "Jobs Not Open Report"
DoCmd.OpenReport stDocName6, acNormal

stDocName7 = "Jobs Not Open Report"
DoCmd.OpenReport stDocName7, acNormal
 
Sounds like a sync problem. Code runs through all your commands, but later
ones depend on earlier queries which havent finished executing yet. Try
putting some Doevents commands between each operation to slow things down a
bit. Not a full solution, because Doevents still does not wait for the
previous op to finish before running the next. This can be quite difficult
on a multithreaded operating system like Windows. Ideally you should set a
public flag in each operation, and loop until the flag is set before
proceeding to the next operation, but this can be difficult when your op is
just a query.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Back
Top