SET UP A TEXT BOX TO FLASH RED/BLACK WHEN A DATE IS PAST DUE

This MSAccess tutorial explains how to set up a text box to flash red/black when a date is past due in Access 2007 (with screenshots and step-by-step instructions).

See solution in other versions:

Question: In Microsoft Access 2007, I’ve built a database for my office use. My problem is how do I make the fore color in the date field flash red and black whenever the date is overdue?

Answer: To set up an object to flash red and black, you need to place VBA code on the Form’s “On Timer” event.

First, select the “On Timer” property on the Form. A button with 3 dots should appear to the right. Click on this button.

Microsoft Access

When the Choose Builder window appears, highlight Code Builder and click on the OK button.

Microsoft Access

Next, insert code on the “On Timer” event as follows:

Private Sub Form_Timer()

   If [Required_Date] < Date Then
      If [Required_Date].ForeColor = vbRed Then
         [Required_Date].ForeColor = vbBlack
      Else
         [Required_Date].ForeColor = vbRed
      End If
   End If
   
End Sub

In this example, the VBA will flash the Required_Date field (ie: forecolor) as red/black if the date is overdue.

Microsoft Access

Next, you need to set the Timer Interval. Go back to the Properties for the Form and set the “Timer Interval” property.

Microsoft Access

In this example, we’ve set the Timer Interval to 1000 milliseconds which is equivalent to 1 second. So the color of the Required_Date field will flash red/black every 1 second.

You can set the Timer Interval to any value between 0 and 2,147,483,647, as appropriate.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s