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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternate Shading Question 2

Status
Not open for further replies.

Noel2

Technical User
Jan 16, 2003
69
US
I have a report that I have created that shades every other line in the detail section with the following code:

Const XorToggle = 4144959

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

which is placed in the on Format property of the report. The problem that I am having is that I would like at each different group for the alternate shading to restart. Right now at the start of one group it is white and the next group the start has the possibility of being either gray or white. I would like at the start of each group for the first record to be white. Please let me know what I can do.

Thank you.
Noel
 
The code you have works great, but I am unsure how to modifiy it to your needs....Maybe the creator (MichaelRed, I think) can help you out. In the meantime, here is a solution that will work.

Use the following code instead of the one you currently have in your Detail.OnFormat event:

Const colWhite = 16777215
Const colGrey = 12632256

If Me.Detail.Backcolor = colWhite Then
Me.Detail.Backcolor = colGrey
Else
Me.Detail.Backcolor = colWhite
End If

Then place the following in the GroupHeader.OnFormat event:

Me.Detail.Backcolor = 12632256

That shoudl do it for you, because you are forcing the grey to be applied everytime you change groups....thereby forcing the first record in a group to always be white. You can do the exact same thing with your other code....I am just unsure of how to apply it with the Xor function. Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCSA, CNA, MCP, Network+, A+
w: robert.l.johnson.iii@citigroup.com
h: mstrmage@tampabay.rr.com
 
Perfect... that should work fine... By the way, do you know how I can change the color of just one field in my detail section instead of the whole section? What about just changing the color of just a section of the detail section instead of the whole detail section? Please let me know. The changing of the color for just one field is really important to me. The other is just a wish list item.

Thank you,
Noel
 
Well....you have a couple of options....

If you are talking about one field....just use the Backcolor of the field in question, instead of the Detail.Backcolor property.....

If you are talking about a section that covers a couple fo fields, while you could just set each on as described above, it would probably be the simpliest to add a rectangle to the report deatils section, make sure it is on the lowest layer level (Menu Bar - Edit - Send to Back) and just use the backcolor of the rectangle....

Again, let me know if you need any assistance... Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCSA, CNA, MCP, Network+, A+
w: robert.l.johnson.iii@citigroup.com
h: mstrmage@tampabay.rr.com
 
I am trying to put this in for the rectangle and this is not working. I got the first problem ironed out. When I use the detail section it works great, but when I specify the box itself it doesn't alternate the color. Below is the code that I am using in the on Format property, I define the intDetailNum in the main report declarations and set it to 0 in the on Open property. I have looked several times at this trying to figure it out and I am coming up blank. If need be I will send you the report in a file so that you can check it out. I know it probably is a quick fix but I can't figure it out:

Dim lngBackColor As Long

If intDetailNum Mod 2 = 0 Then
lngBackColor = 12632256 ' Grey
Else
lngBackColor = 16777215 ' White
End If

Me.Box25.BackColor = lngBackColor

intDetailNum = intDetailNum + 1

Thanks!
Noel
 
First...make sure the box's back style property is set to normal....by deafult it is set to transparent and you won't see any changes happening...

If that doesn't work...send me an email and I will forward you the sample I am putting together. Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCSA, CNA, MCP, Network+, A+
w: robert.l.johnson.iii@citigroup.com
h: mstrmage@tampabay.rr.com
 
Man, you are amazing... I can't believe it was something that simple. Now I am having another problem though. I have a line that is drawn on Format as well. When the box is gray it is covering up the line. Is there a way to bring this line to the front to fix this problem when it is drawn. Here is the code that I am using now for the on Format routing:

Dim lngBackColor As Long

If intDetailNum Mod 2 = 0 Then
lngBackColor = 12632256 ' Grey
Else
lngBackColor = 16777215 ' White
End If

Me.Box25.BackColor = lngBackColor

intDetailNum = intDetailNum + 1

Me.ScaleMode = 1
Me.ForeColor = 0
Me.DrawWidth = 12

Me.Line (3 * 1440, 0)-(3 * 1440, 14400)

Please let me know if you know how I can correct this.

Thank you very much for all of your hard work!
Noel
 
Sure...same as with the rectangle....enter the report in design mode. select the line, in the menu bar click Format -> Bring to Front.....this will force the line to be ni the top layer of the report....thereby having it always "appear" on top. Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCSA, CNA, MCP, Network+, A+
w: robert.l.johnson.iii@citigroup.com
h: mstrmage@tampabay.rr.com
 
The line isn't an object in the report until the On Format command. It is actually created through the code and placed on the report only on formatting. Please let me know if you have any ideas.

Thanks!
Noel
 
Nope...not that I can think of.

Myself, I would put the line on the report and just change the size and set the visible property on and off as necessary....

That way, you can make sure th line is on the top layer, you can hide it when necessar, and adjust the length as you need..... Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCSA, CNA, MCP, Network+, A+
w: robert.l.johnson.iii@citigroup.com
h: mstrmage@tampabay.rr.com
 
The only reason that I have it set up the way that I do, is so that the line will always be the length of the detail section. I haven't been able to do this any other way except by setting the line up through code.

Thanks!
Noel
 
Well, again I stress....just put the line there and use the length property as you currently are just to modify the length and visibile property as necessary...should work the same as you are currently doing....all you would do is instead of creating it, just modify it's properties.... Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCSA, CNA, MCP, Network+, A+
w: robert.l.johnson.iii@citigroup.com
h: mstrmage@tampabay.rr.com
 
okay... I was just concerned with as the height of the section grows due to field values that the height of the line will grow as well.

Thanks
Noel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top