[AccessD] DoEvents - How should this command be used in Access?

Dan Waters dwaters at usinternet.com
Wed May 23 08:57:31 CDT 2007


John & Jim,

Thanks for your explanations.  Would you believe that I now understand what
Help was trying to say?

The problem I was having is when a file was copied from a server to a client
temp folder and then immediately opened by hyperlink.  Occasionally an error
would be recorded which said "Can't find file", so I guessed that the
copying by Windows wasn't complete so the file couldn't be opened.  I'll put
DoEvents in front of the hyperlink code and see how it goes!

Thanks!
Dan

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Tuesday, May 22, 2007 9:22 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] DoEvents - How should this command be used in Access?

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

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com






















































































































































































More information about the AccessD mailing list