Color Coding a record in the detail section

  • Thread starter Thread starter ChuckW
  • Start date Start date
C

ChuckW

Hi,

I have three types of records in the detail section of my record. One is
2007Actual, the second is 2008Atual and the third is 2008Budget. The other
fields are CustomerName, Jan, Feb, Mar etc. I want to color code all records
that have the Type field as 2008Budget. Is there a way to do this?

Thanks,
 
Hi,

I have three types of records in the detail section of my record. One is
2007Actual, the second is 2008Atual and the third is 2008Budget. The other
fields are CustomerName, Jan, Feb, Mar etc. I want to color code all records
that have the Type field as 2008Budget. Is there a way to do this?

Thanks,

Code the Detail Format event:
If Me![Type] = "2008Budget" then
Me.Section(0).BackColor = 12632256
Else
Me.Section(0).Backcolor = vbWhite
End If

For best appearance, make sure the BackStyle of each control is set to
Transparent.

NOTE :
Type is a reserved Access/VBA/Jet word and should not be used as a
field name. Change the field name [Type] to something else.

For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

For an even more complete list of reserved words, see:
http://www.allenbrowne.com/AppIssueBadWord.html
 
ChuckW said:
I have three types of records in the detail section of my record. One is
2007Actual, the second is 2008Atual and the third is 2008Budget. The other
fields are CustomerName, Jan, Feb, Mar etc. I want to color code all records
that have the Type field as 2008Budget. Is there a way to do this?


Not sure how you determine which record type each record
belongs to, but I will assume it's a field in the record
source.

You can set the section's BackColor by using a little code
in the detail section's Format event procedure:

If Me.typefield = "2008Atual" Then
Me.section(0).BackColor = vbYellow
Else
Me.section(0).BackColor = vbWhite
End If

You may also want to set all the label and text box
control's BackStyle to Transparent.
 
Back
Top