Automatically Formatting Text in a report

striker

Useless and getting worse
Local time
Today, 00:12
Joined
Apr 4, 2002
Messages
65
I done a reasonable amount of research and I do't believe I can do what I want within the report.


I have a task outstanding report and want to format the text differently depending how far out of date the task is.

ie under 30 days late in bold
between 30 and 60 days late in bold italics
over 60 days old in flashing red 128 pitch font.

Is this possible and how.


TIA
Steve.
 
Are you using A2K or above? If so, in the reports design view, select the text field you want to format and goto Format >>> Conditional Formatting. From here you can set the conditions of the field.

IMO
 
Fraid not good old 97.:confused:
 
You could try messing about with the reports detail, like....
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.YourTextField.Value < 30 Then
Me.YourTextField.ForeColor = vbBlue
End If

If Me.YourTextField.Value > 30 And Me.YourTextField < 60 Then
Me.YourTextField.ForeColor = 16744703
End If

If Me.YourTextField.Value > 60 Then
Me.YourTextField.ForeColor = vbRed
End If

End Sub

Hope this helps

IMO
 
Last edited:
I think this is a bit closer to what you want...
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.YourTextField.Value < 30 Then
Me.YourTextField.FontBold = False
Me.YourTextField.FontItalic = False
Me.YourTextField.ForeColor = 0
End If

If Me.YourTextField.Value > 30 And Me.YourTextField < 60 Then
Me.YourTextField.FontBold = True
Me.YourTextField.FontItalic = True
Me.YourTextField.ForeColor = 0
End If

If Me.YourTextField.Value > 60 Then
Me.YourTextField.FontBold = True
Me.YourTextField.FontItalic = True
Me.YourTextField.ForeColor = vbRed
End If

End Sub
IMO
 
Last edited:
IMO,


Thanks for the help works like a dream.
 
what about....

what if the field that i wanted to format was a date field... how would i modify the code you provided?
 
Much the same, something like...
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.YourDateField.Value < #1/30/2001# Then
Me.YourDateField.FontBold = False
Me.YourDateField.FontItalic = False
Me.YourDateField.ForeColor = 0
End If

If Me.YourDateField.Value > #1/30/2001# And Me.YourDateField.< #1/30/2006# Then
Me.YourDateField.FontBold = True
Me.YourDateField.FontItalic = True
Me.YourDateField.ForeColor = 0
End If

If Me.YourDateField.Value > #1/30/2006# Then
Me.YourDateField.FontBold = True
Me.YourDateField.FontItalic = True
Me.YourDateField.ForeColor = vbRed
End If

End Sub
changing "YourDateField" to the name of the control and the dates accordingly.

IMO
 
Conditional ~ using current date

I'm using Access 97 so I can't use the conditional formating to build by report. I was wonder, how would I accomplish this:

I have a report and I want the most current record (using a date field to print) a different color, in other words how would I code it that I only need the most recent date?
 
formatting

teiben,

I assume that you can't sort the report so that the newest date is the first record.

If you can't then you will have to sit down and think up some formula to work out the most recent date.

Give me some info on the size the report is likely to be ie how many records. and how big the table is etc and i'll try and come up with an answer.
 
This will return the latest date on the Report in Bold/Red...
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.YourDateControl = DMax("YourTableColumn", "YourTable") Then
    Me.YourDateControl.FontBold = True
    Me.YourDateControl.ForeColor = vbRed
Else
    Me.YourDateControl.FontBold = False
    Me.YourDateControl.ForeColor = vbBlack
End If

End Sub
and in the Reports properties...

Filter On = Yes
Order By = [YourDateControl] Desc
Order By On = Yes

will list them in Descending Order.

IMO
 
Last edited:
I guess I'm brain dead, but what am I doing wrong?

The report is sorting Date Recd as desenting
The tablename is Bla
The Date_Recd is the field

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.Date_Recd = DMax("[Date_Recd]", "Bla") Then
Me.Date_Recd.FontBold = True
Me.Date_Recd.ForeColor = vbRed
Else
Me.Date_Recd.FontBold = False
Me.Date_Recd.ForeColor = vbBlack
End If

End Sub
 
teiben said:
The Date_Recd is the field
Is the column name in the table Bla "Date_Recd"? If not, you need to put the column name from Table Bla in the DMax code line, not the field name from the report.
Code:
If Me.Date_Recd = DMax("[Table Bla Column Name Here]", "Bla") Then

IMO
 
Last edited:
I figured it out, if it's based on a table it works, but if I base it on a parameter query, it doesn't
 

Users who are viewing this thread

Back
Top Bottom