Use color to flag Access form fields

Colorizing a form field can bring important data to your notice. Mary Ann Richardson details a trick that tells Access to change the color of a field depending on its value.

When working with forms, it is often hard to zero in on the important data. Color is one way you can ensure certain data stands out from the rest. For example, you can use color to emphasize that a customer has a $0 balance and, therefore, is eligible for a cash discount. Follow these steps:

  1. Open the form in Design View.
  2. Right-click the form and select Properties.
  3. Click the drop-down arrow under Selection Type and select Form (Figure A).

Figure A

field properties

  1. In the Event tab, click the On Current property box, click Event Procedure, and then click the Build button (Figure B)

Figure B

Event procedure

  1. Enter the following code at the prompt:
If Me.Balance > 0 Then

With Me.Balance

.ForeColor = vbWhite

.BackColor = vbRed

.FontBold = True

End With


With Me.Balance

.ForeColor = vbBlack

.BackColor = vbWhite

.FontBold = False

End With

End If

  1. Press Alt + Q.
As you scroll through the records, the Balance field format will change as the field value changes (Figure C).

Figure C

Alt = Q

Miss an Access tip?

Check out the Microsoft Access archive and catch up on other Access tips.

Help users increase productivity by automatically signing up for TechRepublic's free Microsoft Office Suite newsletter, featuring Word, Excel, and Access tips, delivered each Wednesday.