Form not showing

B

BruceS

Hi, All.

Have a form with a button that, when clicked, opens a unbound, pop-up, modal
form that is supposed to automatically perform a series of queries, file
copies, etc. On the pop-up is a text box that tells the user what is going
on, primarily showing the file names as they are being processed. (Purpose
here is to allow user to know which file had an error if something goes
wrong, and to let them know that the program is actually doing something.)

My Problem: The pop-up form does not show on the screen until its
processing is finished and I make an "OK" button visible, which is used to
close the form. I originally had the operational code in Form_Load, then
tried moving it to Subs called by Form_Load. I'm guessing that, because the
code is run (directly or indirectly) from the Load event, it never paints the
screen until it's finished. I've tried inserting me.Repaint and me.Refresh,
and then following them with DoEvents. No luck.

Only way I've found to get the form to display is put a button on it that
the user must click to start the process. This is redundant, because they've
alread told it to start.

How can I get the processing to be visible while it occurs, without the
additional button and required response?

Thanks,
Bruce
 
W

Wayne Morgan

The code is running and tying up the processor. You need to put the command

DoEvents

before the running of each query to give the system time to do other things.
Also, to force the display of the form use the following command in the Open
event:

Me.SetFocus

and make DoEvents the first command executed in the Load event. You can use
DoEvents as often as you want. Placing it before items that will take a long
time or in a loop that will run for a long time will make the system more
responsive. It may also slow down what you're doing if the system is working
on a lot of other things, since you'll be releasing CPU time to them. If
there is nothing else going on, you won't notice the difference in the time
it takes your code to run, but will probably notice the increased
responsiveness of the system.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top