Change text box color

  • Thread starter Thread starter Kirstie Adam
  • Start date Start date
K

Kirstie Adam

Hey all,

I have a report which looks like a table

Jan Feb Mar Apr etc..
Books In 2 3 2 4
Books Out 1 3 6 5 etc..

The months are just plain old labels, but i would like to fix it so that
when i open the report, the month we are currently are in will highlight
in yellow. e.g. This month the July label would be yellow, but next month
it would be August.

Can anyone help?

Kirstie
 
Kirstie said:
I have a report which looks like a table

Jan Feb Mar Apr etc..
Books In 2 3 2 4
Books Out 1 3 6 5 etc..

The months are just plain old labels, but i would like to fix it so that
when i open the report, the month we are currently are in will highlight
in yellow. e.g. This month the July label would be yellow, but next month
it would be August.

You would need a way to identify the label (and text boxes?)
you want to highlight. In a simple case like this, I
suggest using a regular naming pattern for the control names
(e.g lblMonth1, lblMonth2, etc). Then, you can use code in
the report's Open event to change the appropriate control's
baxk color property. E.g.

Me("lblMonth" & Month(Date)).BackColor = vbYellow
and/or
Me("txtBooksIn" & Month(Date)).BackColor = vbYellow
Me("txtBooksOut" & Month(Date)).BackColor = vbYellow
 
Kirstie,
I assume the labels are located in the Page Header.
If so, add a Report Header to the Report if you don't already have one.
Code the Report Header Format event:

Dim L As Label
For Each L In Me.Section(3).Controls
If L.Caption = Format(Date, "mmm") Then
L.BackColor = vbYellow
Else
L.BackColor = vbWhite
End If
Next L
' Cancel = true ' *

* If you don't need a report header just remove the first ' from the Cancel
= True line.
 
Back
Top