Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shading rows of a report 6

Status
Not open for further replies.

ind

Programmer
Mar 9, 2000
121
US
How can shade rows in a report (gray)

Example:

Row 1 = Transparent
Row 2 = Gray
Row 3 = Transparent
Row 4 = Gray
ect.

Thanks
 
Hi ind,
Haven't tested this, but this might be something you could try:

In the form module, set module-level variable:
dim intDetailNum as Integer

Then in Detail_Format procedure:
dim lngBackColor as long

if intDetailNum Mod 2 = 0 Then
lngBackColor = 16777215 ' White
else
lngBackColor = 12632256 ' Grey
end if

Detail.BackColor = lngBackColor

intDetailNum = intDetailNum + 1


And in Report_Open:
intDetailNum = 0

Please let me know if that works (I don't really know if it will or not..)
 
Thanks for help
It works like a charm
GOOD WORK!!!!!!!!!!!!
Thanks again
 
Katerine,

Thanks for posting that tip! I used it in a report to highlight any row of info where the date was greater than another date.

I kept using "me.backcolor" with no results until I saw you use "DETAIL.backcolor" and then the lights and sirens started going off in my brain!

Thanks a lot Katerine. Now my report looks really snazzy!

Regards,
Zaza
 
Not sure how the MOD portion of your coding works. What is the MOD doing in the above case?

Thanks,

Jenny
 
Jenny,

Mod returns the remainder part of a division so 2 Mod 2 returns 0, 3 Mod 2 returns 1. It's being used to check if the line is numbered odd or even.

Could equally use If intDetailNum/2 = Int(intDetailNum/2) if it's clearer to you.

Craig
 
Jenny,

A breif description can also be found in the Access help under "Mod operator".

ZaZa
 
Hmmmmmmmmmmmmmmm,


Much ado about the complicated approach. While you still need to set ALL of the controls background to transparent, the following will also alternate the shading effect for a report - with less code. NOTE, it does depend on the backcolor being left as "white" in the design. You can get some interesting effects if it is not.

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

    'Michael Red.   2/13/2002.      To 'Toggle the backolor, which
    'Provides alternate line shading
    Const XorToggle = 4144959

    Me.Detail.BackColor = Me.Detail.BackColor Xor XorToggle


End Sub
 MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
ZaZa,

Please share with me how you made your report shade depending upon dates. I have been working on this all afternoon and haven't had much luck.

Thank you for the help!
Christy
 
if intDetailNum Mod 2 = 0 Then

[tab]changes to

If (DateField > Condition) Then

Substuiting the appropiate parts ((DateField, >, Condition)

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
ChristyT,

I had two date fields on my report that i wanted to compare: Me![Date1] and Me![Date2]. If date2 was later than date1, I wanted the entire row in the report to be grey. SO leaving out the mod parts of Katerine's code I just used the following on the format event of the deatil section:

---------------------------

Dim lngBackColor As Long

If Me![Date2] > Me![Date1] Then
lngBackColor = 12632256 'Grey
Else
lngBackColor = 16777215 'White
End If

Detail.BackColor = lngBackColor

-----------------------------

Hope that helps you,
ZaZa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top