jwcolby
jwcolby at colbyconsulting.com
Tue May 22 21:21:40 CDT 2007
Dan, >Where would it be useful to use the DoEvents command be used in an Access application? It is used inside of tight loops when you want to allow the operating system, or your application, to perform some other business. For example if you were to open a million records in a table and start formatting them and pushing them out to a text file, the process of doing so would lock a lot of computers up tight, in fact pretty much any single core machine. You could actually try to update a control on a form with perhaps a line number or something and the text box would not change, even though you were writing to it. The reason is simply that the VB application is not yielding any processor cycles back to Windows to allow it time to refresh the screen. By placing a DoEvents inside of the loop you can allow the mouse to move, text boxes to update, even entire other applications to do some (though still probably not much) processing. You need to understand what you are doing however when you use DoEvents. Each call to Doevents can take a fair amount of time, depending on what else the OS is trying to do. As a result you can slow down the program quite a bit. If speed nis important however you might want to call DoEvents every 100th iteration of the loop or something like that. In the lingo, there is "pre-emptive multi-tasking" (the OS slices up time and assigns slices to tasks) and co-operative multi-tasking (each task yields control occasionally back to the OS). DoEvents is co-operative multitasking. The Windows OS is supposed to use pre-emptive multi-tasking but in fact it does so very poorly. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters Sent: Tuesday, May 22, 2007 8:48 PM To: 'Access Developers discussion and problem solving' Subject: [AccessD] DoEvents - How should this command be used in Access? Hello to everyone! Where would it be useful to use the DoEvents command be used in an Access application? Thanks! Dan Waters -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com