Labels not repainting

LEXCERM

Registered User.
Local time
Tomorrow, 05:59
Joined
Apr 12, 2004
Messages
169
Hi there,

I have the following piece of code on a command button on a form:

Me.lblRefresh.Visible = True

Dim ctl As control
For Each ctl In Me.Controls
If ctl.Tag = "RefreshStats" Then
ctl.Requery
End If
Next ctl

Me.lblRefresh.Visible = False

The label is not visible when I execute the code via command button. However, if I step through the code, the label works like a charm. I've added Me.Repaint, DoEvents etc, but to no avail. Could it be that the code is running too quickly for it to appear?

Thanks in advance.
 
You have asked it to be invisible here ??
Code:
Me.lblRefresh.Visible = False
 
Thanks for replying pr2-eugin.

I'm wanting the label to be visible before the "for each" calculation takes place (the label has a caption of '...refreshing'), then dissapear when complete.

Cheers.
 
Right got it.. I am sorry I did not read it properly the first time.. Normally it will take micro seconds to execute stuff like this (i.e looping through controls).. So it might not be visible..
 
Sorry I didn't explain myself in the first place.

Yeah, I'd sort of gathered that it would be the case re: speed of code execution. How/where could I place a half-a-second pause within this code?

Thanks again.
 
why don't you try this,

Me.lblRefresh.Visible = True

If Me.lblRefresh.Visible = True then
GoTo strtCode
End If
Exit Sub

strtCode:
Dim ctl As control
For Each ctl In Me.Controls
If ctl.Tag = "RefreshStats" Then
ctl.Requery
End If
Next ctl

Me.lblRefresh.Visible = False

it looks wired but sometimes it works, that could cover the half-second, so after making the control visible, the code will go to check if it is visible and then after finding it the code will run to the next step and that could cover the Gap on the time.
hope it works :) becareful I have exit the sub after the If Function, so make sure you don't have codes running in between.
 
Thanks for your replies.

I've gone for a loop at the end which seems to do the trick:-

Me.lblRefresh.Visible = True

Dim ctl As control
For Each ctl In Me.Controls
If ctl.Tag = "RefreshStats" Then
ctl.Requery
End If
Next ctl

Dim i As Integer
i = 1
Do Until i > 1000
i = i + 1
DoEvents
Loop

Me.lblRefresh.Visible = False
Thanks for your input people. :)
 

Users who are viewing this thread

Back
Top Bottom