Solved

Replacement for DoEvents

Posted on 2012-03-15
7
282 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

896 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now