Any suggestions on why this (a timer) doesn't work?

I

Isaac

I am trying to make a label appear on a form for a short period of time and
then disappear. It starts out invisible when form loads. I know there are a
number of ways of doing this, but I don't understand why my way (below) does
not work. The label just does not appear.

____________
Sub....
'Some stuff
..
..
..
Me!Label28.Visible = True

Call delay(10000)

Me!Label28.Visible = False

End Sub
_________
Private Sub delay(time As Long)
Dim loopindex As Long
loopindex = 1
Do While loopindex < time
loopindex = loopindex + 1
Loop
End Sub
 
B

Brendan Reynolds

This worked for me ...

Me.Label0.Visible = Not Me.Label0.Visible
DoEvents
delay 10000000
Me.Label0.Visible = Not Me.Label0.Visible
DoEvents

Note two things. First, the use of DoEvents. Second, on my system your loop
ran so fast that even with the DoEvents there was nothing but a barely
perceptible flicker with a value of 10000. I had to add another three zeros
to get a noticeable delay. This will, of course, be highly dependent on the
processor speed of the target PC.

You might want to try using the 'Sleep' API function instead. There's code
to use this function at the following URL ...

http://www.mvps.org/access/api/api0021.htm
 

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