Highlight textbox based on date

N

NeoFax

I have a crosstab report that has the days of the month across the top
as "column headings" and workcenters as rows with accomplished hours
as the data. I would like to highlight todays column each day. Here
is what my report looks like:

Helo(Group header)
Station W/C 1 2 3 4 5 6 7 8 9 10 11 12 13 14
15 .... 31 Total
1STA Elec x x - - x x x x x - - x x
x x...

What I would like is if Day(Now()) = 15 then column 15 would
highlight. However, I really do not want to write 31
If..Then..ElseIf..Else code. My data textboxes follow a standard of
txt15 (txt plus the date number). Is there a way to basically state
like Day(now()) = stgTextbox. Me.stgTextbox.backcolor = rgb(255,0,0)?
 
J

John Spencer

Something like the following UNTESTED snippet where your controls are named
Txt1 to Txt31.

For I = 1 to 31
IF Day(Date()) = I Then
Me("Txt" & I).BackColor = rgb(255,0,0)
ELSE
Me("Txt" & I).BackColor = vbwhite
END IF
Next

Or even simpler in your case
Me("Txt" & Day(Date()).BackColor = rgb(255,0,0)

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
N

NeoFax

Something like the following UNTESTED snippet where your controls are named
Txt1 to Txt31.

For I = 1 to 31
   IF Day(Date()) = I Then
      Me("Txt" & I).BackColor = rgb(255,0,0)
   ELSE
      Me("Txt" & I).BackColor = vbwhite
   END IF
Next

Or even simpler in your case
    Me("Txt" & Day(Date()).BackColor = rgb(255,0,0)

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County



NeoFaxwrote:



- Show quoted text -

Thanks! It worked great!
 

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