Change text box color

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
 
M

Marshall Barton

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
 
F

Fredg

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.
 

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

Top