Formatting detail records based on a field value not shown in the report

T

Tom

Hi. What's the general syntax for formatting report detail controls'
forecolor based on the value of a field in the report's data source
that isn't shown?

Background: My report's data source includes a field called
IS_HIGHLIGHTED (yes/no data type). I want to highlight the forecolor
of several detail section controls red if the user checks IS-
HIGHLIGHTED for a record in the underlying table.

Is this a Detail_Print action or a Detail_Format action...?

Thanks!
 
M

Marshall Barton

Tom said:
Hi. What's the general syntax for formatting report detail controls'
forecolor based on the value of a field in the report's data source
that isn't shown?

Background: My report's data source includes a field called
IS_HIGHLIGHTED (yes/no data type). I want to highlight the forecolor
of several detail section controls red if the user checks IS-
HIGHLIGHTED for a record in the underlying table.

Is this a Detail_Print action or a Detail_Format action...?


Generally, format affecting actions are done in the Format
event, but I think this one could be done in either.

OTOH, you do not need any code if you are using A2K or
later. Instead use Conditional Formatting (on the Format
menu). This is done by selecting the Expression is option,
setting the expression to:
[IS_HIGHLIGHTED]
and selecting the highlight color in the ForeColor property.
 
P

Pat Hartman \(MVP\)

Access completely rebuilds each report's RecordSource behind the scenes and
eliminates any field that isn't actually bound to a report control. That
means that you need to assign the field to a control (it can be hidden) in
order to refer to it. As Marsh said, either conditional formatting (if
there are a maximum of 4 variations) or the onFormat event of the detail
section.


Select Case Me.SomeField
Case "a"
Me.SomeOtherField.Forecolor = vbRed
Case "b"
Me.SomeOtherField.Forecolor = vbGreen
Case "c"
Me.SomeOtherField.Forecolor = vbBlue
Case Else
Me.SomeOtherField.Forecolor = vbBlack
End Select
 

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