Solved

Replacement for DoEvents

Posted on 2012-03-15
7
280 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 

Author Comment

by:Andy Brown
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry for the delay in comming back to you - that did the trick.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

772 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

16 Experts available now in Live!

Get 1:1 Help Now