MEMORY ERROR When Running Code

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
 
A

Adrian Jansen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top