Flashing Label

G

Guest

Greetings

I am trying to make a label on a form flash for a certain amount of time (5
seconds) then the label will become invisible, and some other controls become
visible. I can't seem to get the timer event to work right. Here is the most
recent code;
Option Compare Database
Option Explicit
Dim intTime As Integer

Private Sub Form_Load()

intTime = 0
Me.TimerInterval = 500

End Sub

Private Sub Form_Timer()

intTime = intTime + 1


For intTime = 0 To 10

Me.lblLoadMessage.Visible = Not Me.lblLoadMessage.Visible

Next intTime

Me.lblLoadMessage.Visible = False

End Sub

I've tried several variations with Do...Loop statements, If...Then
statements, putting "intTime = intTime + 1" inside and outside of the loop,
etc but nothing seems to work (actually I think it is working, but "intTime"
is incrementing so fast that you don't see anything happening, I could be
wrong though)

Any Ideas?
Thanks in advance
 
M

Mr. B

Greetings

I am trying to make a label on a form flash for a certain amount of time (5
seconds) then the label will become invisible, and some other controls become
visible. I can't seem to get the timer event to work right. Here is the most
recent code;
Option Compare Database
Option Explicit
Dim intTime As Integer

Private Sub Form_Load()

intTime = 0
Me.TimerInterval = 500

End Sub

Private Sub Form_Timer()

intTime = intTime + 1

For intTime = 0 To 10

Me.lblLoadMessage.Visible = Not Me.lblLoadMessage.Visible

Next intTime

Me.lblLoadMessage.Visible = False

End Sub

I've tried several variations with Do...Loop statements, If...Then
statements, putting "intTime = intTime + 1" inside and outside of the loop,
etc but nothing seems to work (actually I think it is working, but "intTime"
is incrementing so fast that you don't see anything happening, I could be
wrong though)

Any Ideas?
Thanks in advance

Try the following code in the On Timer event:

If lngTimeVar < 5000 Then
Me.lblTestLabel.Visible = Not Me.lblTestLabel.Visible
lngTimeVar = lngTimeVar + 250
Else
Me.lblTestLabel.Visible = True
End If

This code will cause the label to flash for 5 seconds and then be just
visible.

HTH

Mr B
 
F

fredg

Greetings

I am trying to make a label on a form flash for a certain amount of time (5
seconds) then the label will become invisible, and some other controls become
visible. I can't seem to get the timer event to work right. Here is the most
recent code;
Option Compare Database
Option Explicit
Dim intTime As Integer

Private Sub Form_Load()

intTime = 0
Me.TimerInterval = 500

End Sub

Private Sub Form_Timer()

intTime = intTime + 1


For intTime = 0 To 10

Me.lblLoadMessage.Visible = Not Me.lblLoadMessage.Visible

Next intTime

Me.lblLoadMessage.Visible = False

End Sub

I've tried several variations with Do...Loop statements, If...Then
statements, putting "intTime = intTime + 1" inside and outside of the loop,
etc but nothing seems to work (actually I think it is working, but "intTime"
is incrementing so fast that you don't see anything happening, I could be
wrong though)

Any Ideas?
Thanks in advance

You only wish to have the label flash when the form opens?

First, set the Form's Timer Interval to 1000 (or 500 to flash more
often)

Next code the Form's Code sheet Declarations section:
Dim dteStartTime as Date

Then ... code the Load event:
dteStartTime =Time()

Next code the Form's Timer event:
If DateDiff("s",dteStartTime,Time()) <=5 then
[LabelName].Visible = Not [LabelName].Visible
End If

Remember, a little of this flashing goes a long way.
 
G

Guest

Thanks fredg, that worked.

BTW thanks Mr.B for responding. I tried your solution but couldn't get it to
work. Not sure why.

fredg said:
Greetings

I am trying to make a label on a form flash for a certain amount of time (5
seconds) then the label will become invisible, and some other controls become
visible. I can't seem to get the timer event to work right. Here is the most
recent code;
Option Compare Database
Option Explicit
Dim intTime As Integer

Private Sub Form_Load()

intTime = 0
Me.TimerInterval = 500

End Sub

Private Sub Form_Timer()

intTime = intTime + 1


For intTime = 0 To 10

Me.lblLoadMessage.Visible = Not Me.lblLoadMessage.Visible

Next intTime

Me.lblLoadMessage.Visible = False

End Sub

I've tried several variations with Do...Loop statements, If...Then
statements, putting "intTime = intTime + 1" inside and outside of the loop,
etc but nothing seems to work (actually I think it is working, but "intTime"
is incrementing so fast that you don't see anything happening, I could be
wrong though)

Any Ideas?
Thanks in advance

You only wish to have the label flash when the form opens?

First, set the Form's Timer Interval to 1000 (or 500 to flash more
often)

Next code the Form's Code sheet Declarations section:
Dim dteStartTime as Date

Then ... code the Load event:
dteStartTime =Time()

Next code the Form's Timer event:
If DateDiff("s",dteStartTime,Time()) <=5 then
[LabelName].Visible = Not [LabelName].Visible
End If

Remember, a little of this flashing goes a long way.
 

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