change color based on different criteria

Y

YPADave

I am trying to set up an access 2003 report that would print out any changes
made after a certain date to print the changes in a different color, while
the remainder of the report prints out in the default color. Any ideas on
how I can do this?
 
D

Duane Hookom

Changes to what? Changes to form or report designs? Changes to data? Changes
to code? Are you asking about tables?
 
J

Joseph

I use this code quite often ( I have several reports that change color):

If (IsNull(Me.Text1) = True) Then
Me.Text1.ForeColor = RGB(255, 255, 255) 'white
Me.Text1.BackColor = RGB(244, 120, 126) 'red
Me.Text1.FontWeight = 300
Me.Text1.FontSize = 8
GoTo Exit_Detail_Format
Else
Select Case diff2dates2("d", Date, Me.Text1, False)
Case 61 To 90
Me.Text1.BackColor = RGB(255, 255, 19) 'yellow
Me.Text1.ForeColor = RGB(0, 0, 0) 'black
Me.Text1.FontWeight = 600
Me.Text1.FontSize = 9
Case 31 To 60
Me.Text1.BackColor = RGB(254, 162, 106) 'orange
Me.Text1.ForeColor = RGB(0, 0, 0) 'black
Me.Text1.FontWeight = 600
Me.Text1.FontSize = 9
Case -800 To 30
Me.Text1.BackColor = RGB(244, 120, 126) 'red
Me.Text1.ForeColor = RGB(0, 0, 0) 'black
Me.Text1.FontWeight = 600
Me.Text1.FontSize = 9
Case Else
Me.Text1.BackColor = RGB(255, 255, 255) 'white
Me.Text1.ForeColor = RGB(0, 0, 0) 'black
Me.Text1.FontWeight = 300
Me.Text1.FontSize = 8
End Select
End If

This changes the font (size,color,weight) and textbox(backcolor) of a date
field based on the datein the textbox and the current date. You would add
this under the Detail.OnFormat. You will have to work on editing the error
handling. This particular report pulls data from a crosstab where if there
is no information the field is null, where as if you were just to pull the
data from a record in a table/query, you might have to change the
IsNull()=True to Len()=0. The variations to this type of code are endless.
You can change the timeline to pick a specific date in a record or a specific
date in time, or to change the color based on the numeric value of the month,
day, year, hour and even minute or second. You could even change it to look
for specific data in a string ,ie (left$([text],1) = "*") would look at the
first character in the string to see if is an asterisk.

This diff2dates2 function is from :

http://www.accessmvp.com/DJSteele/Diff2Dates.html

where I modified the code to not add the identifier('days','hours','months')
for the time periods and made it return an integer instead of a variant.
 
Y

YPADave

The report is for hotel work orders for conferences. We send intial reports
(equipment needs, layouts, times, etc) to the hotel. As changes occur, we
send new reports to the hotel. What we would like is that as we make
changes, the changes would print out in a different color. That way, when
the hotel gets the new report they can see the changes easier insted of
hunting for them.
 
D

Duane Hookom

You still haven't provided any information about tables and fields. You would
have to store the date the changes were made and the date of the last report.
Are you storing this information anywhere?
 

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