-
I am having a problem with my form. When I run the program (which does SQL queries on a Jet dbase) it lists in the Task Manager as Not Responding, and the form doesn't refresh (if you open something else and then come back to the form none of the form stuff, redraws.) However, when the code finally finishes the form refreshes. How do I make it stop listing as Not Responding and refresh?
-
Try placing DoEvents in your code.
-
How would I use DoEvents? Put it at the beginning of the cmdButton_Click event?
-
Hi,
I don't know if this will help in your case, but in the Form_Activate() use the Recordset.Requery statement before your main code, and that way you will refresh the data environment when the form shows.
GRAHAM :)
-
DoEvents
DoEvents commands are usually put inside loops. They give the operating system the chance to do things like repaint the screen that they might not otherwise get the chance to do in a tight loop.
-
My program doesn't use any major loops where a lot of processing occurs. Is there somewhere else I can put the DoEvent statement. Also will I just put DoEvent on its own line, or do I need to assign a variable: MyVar=DoEvent?
Thanks for the help guys.
-
It's DoEvents and it goes on its own line. If a loop isn't the problem then do a Ctrl-Break when the program isn't responding, take a look at where it is and put the DoEvents there.
-
I would think that you should place it in your loop that causes the delay.
-
Thanks for all the help guys, I'll try it.
-
One last thing, does DoEvent work for everything after it?
For example I've got this code in a Click event:
funcFunction1
funcFunction2...etc
If I put DoEvent before the first function call, will it work for all the functions after it?
-
No, DoEvents is just a temporary "pause" that let's the operating system do some work.
-
-
The pause caused by a DoEvents command is not really noticeable. Your problem may have more to do with an SQL query which is taking a long time to return control to your application. Is the database you're querying normalized? If you send a query to a large table, your query will appear to freeze the system.
-
the pause depends what threads windows system is executing on it, you may in worst case wait 10 mins, but thats highly unlikely to happen. usually it takes less than a millisecond.
You can use it in a loop with gettickcount api and you will have a dealy
-
They are fairly long queries. Is there anyway around this, or do I just have to live with it? Which is fine since it's not for districution
-
Well that depends on the system, the end users system ;) but if it's for you and you have a problems with it you have to live with it or get a new one.
-
Can the database you're querying be normalized any more than it is? Querying a small table rather than a large one will save a great deal of time.
-
No, I've already tried to break it into the smallest pieces possible before doing anything major to them. Again thanks for all your help guys.