flashing textbox

  • Thread starter Thread starter JohnE
  • Start date Start date
J

JohnE

I have a text box that is shows a date. I would like to
have the date flash off and on if it is equal to or less
then today's date. I have the following code but it is
not working right.

Private Sub FollowUpDate_Change()
If Me.txtFollowUpDate.Value <= Date Then
Me.txtFollowUpDate.Visible = Not
Me.FollowUpDate.Visible
Else
Me.txtFollowUpDate.Visible = True

End If

End Sub

I someone can see what the error is, please let me know. I
tried to pattern it after the one for a label flashing
that I have.

Thanks in advance for any assistance.
*** John
 
I have a text box that is shows a date. I would like to
have the date flash off and on if it is equal to or less
then today's date. I have the following code but it is
not working right.

Private Sub FollowUpDate_Change()
If Me.txtFollowUpDate.Value <= Date Then
Me.txtFollowUpDate.Visible = Not
Me.FollowUpDate.Visible
Else
Me.txtFollowUpDate.Visible = True

End If

End Sub

I someone can see what the error is, please let me know. I
tried to pattern it after the one for a label flashing
that I have.

Thanks in advance for any assistance.
*** John
You need to use the form's Timer Event...

Private Sub Form_Timer()
If Me.txtFollowUpDate <= Date Then
Me.txtFollowUpDate.Visible = Not Me.txtFollowUpDate.Visible
End If
End Sub

And set the Timer Interval to 500 to flash every 1/2 second.


However keep in mind. Anything flashing on a form can become annoying
very quickly. You might consider just a bold/bright label to alert the
user. My 0.02

- Jim
 
Hi John

You need to use the form's Timer event for this, and you do it by changing
the colour of the text, not by making the whole control visible and
invisible:

Private Function Form_Timer()
Const FlashingColor = vbRed
Const FixedColor = vbBlack
With Me.txtFollowUpDate
If .Value <= Date Then
If .ForeColor = .BackColor Then
.ForeColor = FlashingColor
Else
.ForeColor = .BackColor
End If
Else
.ForeColor = FixedColor
End If
End With
End Sub

This will flash red if it's before today, otherwise stay black.

Set the for's TimerInterval property to be half of what you want the flash
period to be - for example 500 (milliseconds) for a 1 second flash.
 
Jim, your 2 cents is noted. How would I go about just
making the inside color change if the date is less then or
equal to today?
*** John
 
Just use a conditional expression in the AfterUpdate event of the
control. Like

Private Sub txtFollowUpDate_AfterUpdate ()
If Me.txtFollowUpDate <= Date Then
Me.txtFollowUpDate.BackColor = vbYellow
Else
Me.txtFollowUpDate.BackColor = vbWhite
End If
End Sub

Also, you should probably put the same expression in the form's On
Current event - time has a way of passing.

- Jim
 
Back
Top