Click to See Complete Forum and Search --> : DoEvents Function
beercat
Nov 12th, 1999, 02:16 PM
Ok, here's my question... I understand that the DoEvents function passes control back to the operating system (although it's not exactly clear what that does). Anyway, I support an application that was written with Access 95 VBA. This app consists of 3 databases which move data from these comma delimited log files into an Access database. Much of this processing happens over a LAN and we've discovered recently that the process slows down SEVERELY at the end. So in going through the code, I found a section that is meant to slow down the program to Access to finish processing before exiting the application. In this procedure a loop of 100 iterations is performed with the only event happening within the loop being a DoEvents command. Does this sound like a good programming practice? When we took it out, for testing purposes, it ran VERY much faster. However, the original programmer clearly commented that they had been having trouble with Access exiting before all processing completed. Is this possible and if so, is there a better way to prevent this than 100 DoEvents commands? PLEASE help me!! Thanks a bunch!
Brian
It's usually necessary to have a DoEvents in a long loop, especially if the user could be doing something else with the program while its looping. The only thing DoEvents really does is complete execute any pending program actions. Without that, your program would in effect freeze until the loop was done.
------------------
Clunietp
Nov 13th, 1999, 10:46 PM
You could try DBengine.Idle method, that is the Access equivalent to the Windows DoEvents method -- but If you don't have a problem with Access exiting, then just comment those lines out, or change it to one or two DoEvents calls
Tom
Gaurav
Nov 14th, 1999, 11:27 AM
Hi,
Well personally i wouldn't like to use a loop of DoEvents. Simply because you never know how many DoEvents you require. 100 is a probably a safe conservative estimate. But it could require more, it could require a LOT less!!
Instead try using the Win API "WaitForSingleObject" this tells you ecactly when a process has completed its operations, and is much more reliable.
Hope this helps.
Cheers,
------------------
Gaurav Mahindra
gmahindra@extentia.com
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.