Solved

Replacement for DoEvents

Posted on 2012-03-15
7
286 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

860 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