Solved

Replacement for DoEvents

Posted on 2012-03-15
7
288 Views
Last Modified: 2012-04-11
I have a form (well several actually) that perform specific functions.  When running it updates the forms caption to tell the user what is happening.  

To avoid the "Not responding" message at the top of the form (whilst the process is running), I have been using the DoEvents command.  However, this can cause other knock on effects (especially across slower networks).

Is there another command that allows the form message to be updated and clears the "Not responding" message?

Thanks as always
0
Comment
Question by:Andy Brown
  • 3
  • 3
7 Comments
 
LVL 15

Expert Comment

by:Simon Ball
ID: 37723859
It depends what you are updating the form for, if its just to report progress to the user there's the option of using the status bar to update, just like access does when running a big query...

http://msdn.microsoft.com/en-us/library/aa221609(v=office.11).aspx

http://codevba.com/fragments/help.htm?http://codevba.com/fragments/Access_StatusBar.htm

Otherwise you can form.refresh or repaint...but i am not sure the specifics on those as i have tried to use them in the past and some actions do not seem to activate them, as you seem to be finding.
0
 

Author Comment

by:Andy Brown
ID: 37723868
Thanks for your quck response.

I can't use the status bar as it is hidden on this particular app (need as much screen space as possible).

The biggest pain is the "Not responding" message and I don't think Refresh/Repaint clears that - but i'll check.
0
 
LVL 15

Expert Comment

by:Simon Ball
ID: 37723876
are you running big queries or performing lots of processing in sql?

might be worth writing a test app to see if VBA provides natural breaks, such as calling sub procedures for each step, and having actions perform changes to the form in between calling each sub / function.

Or have your code open a seperate form which just has a label saying "processing.... please wait, this can take up to X minutes" and then close the form in the other code when the big piece of work has been done.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:Andy Brown
ID: 37724227
It's all in on sub routine, so I'll try splitting things out and see what happens.

Thanks again.
0
 
LVL 15

Accepted Solution

by:
Simon Ball earned 500 total points
ID: 37724277
could try writing a sub which updates the form, shows info, etc, and call it inbetween other steps

call dosomework1
call updateform(1)
call dosomework2
call updateform(2)

etc
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37724990
Yeah, the "Not Responding" message is a bit confusing...

Most people see it and assume the app is locked, or it crashed...
So they "Ctrl-Alt-Del" out of the program.

Many times it just means that the app is doing something that is just taking a long time.

I fear that there may not be that much you can do to avoid this, that won't cause even more issues under other circumstances.

For example, you can use: Docmd.Echo False
To simply "freeze" the screen
(Then obviously turn it back on with Docmd.Echo True)

But this will cause confusion if an error occurs and your error handier does not turn Echo back on...


DoEvents is similar to Sendkeys in that it is a "Brute Force" way of doing something.
With each new release of a MS Programming platform, they always threaten to deprecate it.


Always go back to the beginning, ...instead of focusing on "working around" this situation, ...How about trying to eliminate it in the first place?
;-)

Are you 100% sure that these "specific functions" are as streamlined and efficient as possible?
Running recordsets (and/or not closing them properly) where SQL could be used
Poor Indexing
Poor Variable declarations
Inefficient Loops
Doing things for "All" records, when it is only needed for certain records.
Complex AND/OR Logic
Using Wildcards
Using too many Aggregate functions.
...even having an un-normalized table design...
...etc

You have not posted any details on these "specific functions."
...Perhaps you could enlighten us...?

JeffCoachman
0
 

Author Closing Comment

by:Andy Brown
ID: 37832179
Sorry for the delay in comming back to you - that did the trick.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question