Repaint a form

W

Warrio

Hello!

Why the function repaint stops working as soon as I put a progress bar in
the form?
I change the value of the progressbar and do other action in a loop, but
mean while, I want the progress bar to be refreshed so it has the right
value..
as a result, my form freezes the hole loop time.. and at the end the
progress bar value is full (100%)

the code looks like:

For i = 1 to rs.RecordCount
myProgressBar.Value = i * 100 / rs.RecordCount
me.Repaint
...
... 'Other actions...
Next i

Thanks for any suggestion
 
M

Michel Walsh

Hi,


Have you tried to add a DoEvents before the me.Repaint ? The Paint message
(and the Timer message) are "low priority" (well abusively call so, since
not linked to the thread priority) and they are not immediately considered
if there is something else to be executed, they are push back on the message
queue. DoEvents just try to allow other messages to be executed, so the
Painting message would be immediately considered, hopefully... rather than
at the end of the loop.


Hoping it may help,
Vanderghast, Access MVP
 
W

Warrio

Hello!
Thanks again! it works perfect!


Michel Walsh said:
Hi,


Have you tried to add a DoEvents before the me.Repaint ? The Paint message
(and the Timer message) are "low priority" (well abusively call so, since
not linked to the thread priority) and they are not immediately considered
if there is something else to be executed, they are push back on the message
queue. DoEvents just try to allow other messages to be executed, so the
Painting message would be immediately considered, hopefully... rather than
at the end of the loop.


Hoping it may help,
Vanderghast, Access MVP
 

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