Loop and DoEvents

ASherbuck

Registered User.
Local time
Today, 15:11
Joined
Feb 25, 2008
Messages
194
Greetings,

I have an 07 package that I'm using to parse information, everything is uniform and comes from xml files. I've got 3 parts that I am using and looking for a little advice with the crashing I am having.

The program loop is setup like such:

Loop1 For ...
|
--Loop2 For ...
|
--Loop3 For ...

Next Loop3
Next Loop2
Next Loop1

Loop1 Sets data retrieval criteria, basically "Bring me records that match . . . Price between $$$ and $$$" and is set to increase with each loop until it reaches a set amount.

Loop2 opens a specific file and displays the results in Access. It starts with the first result, and loops until it gets to the last result.

Loop3 parses all the results for that file. Item Information, Prices, barcodes, etc.

To me this means it will pull the results, pull the first page, parse the first page, then pull the 2nd page, parse the second, pull the third, parse the third page and if the 3rd page was the last page it would hit loop1 and pull the next set of results that match the now incremented criteria.

It normally works fine, all my data is where it needs to be, it's fast and efficient, but I get this random crash where it doesn't ask me to go into break mode it just locks up and says "Access has encountered a critical error and must shut down. Do you want to report this error to Microsoft."

It doesn't give me and error number to look up. It comes at irregular intervals. I was running it on 2 seperate computers, one it runs fine on. Oddly the one it ran well on was a Vista box.

I can post code or get more specific but does anyone have any ideas as to why this would go caput ?

*EDIT* On the advice of a friend I put a DoEvents before each loop:
DoEvents
Next Loop3
DoEvents
Next Loop2
DoEvents
Next Loop 1

I also have recently freed a lot of hard drive space up. The machine has 4 gigs of ram and only had a couple gigs free on the HD, I had the page file set higher than the free space, so I cleared a large amount off.
 
Last edited:
In my opinion, this could be a number of things:

Memory Access Error, OverFlow, Out Of Stack Space, etc.

Without a error number it's difficult to really tell.

Ensuring that objects are closed properly and killed after every use will provide a far more reliable result than if they are not.

System memory and the availability of it can play a large role as to how your overall Computer system will run and how the applications within it will perform.

.
 
Since clearing out space and adding the DoEvents Ive seen a noticeable improvement, namely it ran all day and didn't freeze up or crash.

It's actually doing what I want it to on a consistent basis.
 

Users who are viewing this thread

Back
Top Bottom