Flashing color on a control background

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

I need to flash a control background color on a form according to the
condition that the date is within 10 days in advance of the set date on
Access 2003. Can someone advise how to accomplish it.

Thanks,

Scott
 
You really sure you want to do this? Many people despise flashing controls,
and for some epileptics, it can be very hazardous...

Assuming we're not talking about a continous or datasheet form, if the
condition is met, set the form's TimerInterval property to an appropriate
value (if you want it to flash every half second, for instance, you'd set it
to 500), then put code in the form's Timer event to change the control's
BackColor property:

Private Sub Form_Timer()

If Me.MyControl.BackColor = vbRed Then
Me.MyControl.BackColor = vbGreen
Else
Me.MyControl.BackColor = vbRed
End If

End Sub

Don't forget to set the TimerInterval property back to 0 when you no longer
want the flashing.
 
I need to flash a control background color on a form according to the
condition that the date is within 10 days in advance of the set date on
Access 2003. Can someone advise how to accomplish it.

Thanks,

Scott

Set the Form's Timer Interval property to 1000

Assuming the name of your date control is [ADate], then
code the Form's Timer event:

If Me![ADate] - Date >= 0 And Me![ADate] - Date <= 10 Then
If [ADate].BackColor = vbWhite Then
[ADate].BackColor = vbRed
[ADate].ForeColor = vbYellow
Else
[ADate].BackColor = vbWhite
[ADate].ForeColor = vbBlack
End If
Else
[ADate].BackColor = vbWhite
[ADate].ForeColor = vbBlack
End If

Use very sparingly as it becomes annoying very quickly.
 

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

Back
Top