I know I have seen the answer on one of the forums. How do I print every other record in gray? You help is greatfully appreciated.
BTW, can anyone tell me why this doesn't work too?<br><br>Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)<br> If PrintCount Mod 2 = 0 Then<br> Me.Detail.BackColor = 12632256 ' grey<br> Else<br> Me.Detail.BackColor = 16777215 ' white<br> End If<br>End Sub
<br>That's, "either"..., we'll see multicolor reports from now on.<br><br><br>Dim strGrey<br><br>Sub Report_Open(cancel as integer)<br> strGrey = &Hc0c0c0<br>End sub<br><br>Sub DoGrey()<br> me.section(0).backColor = IIF(strGrey, &Hc0c0c0, &HFFFFFF)<br> strGrey = not strGrey 'toggle the color, any color<br>End Sub<br><br><br>Sub Detail_Format(Cancel as Integer, FormatCount as Integer)<br> DoGrey<br>End Sub<br><br><br>Let me know if this worked for you.<br><br><br><br> <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
This should do the trick:<br><br>Public Function ShadowAlternateLines()<br>If CodeContextObject.Section(0).BackColor = 16777215 then<br>CodeContextObject.Section(0).BackColor = 14869218<br>Else<br>CodeContextObject.Section(0).BackColor = 16777215 <br>End If<br>End Function<br><br>Now, all you need to do is call this function from the Detail Section Format Event of any report. Just type<br>"=ShadowAlternateLines()" <br>into the Format Event, and it's done. There's no need to code an event procedure.<br><br>You can use the same technique to "underline" alternate lines. To do this, draw a line under the detail text on your report, and make it's name txtUline. Code the following public function as before:<br><br>Public Function UnderlineAlternateLines()<br>CodeContextObject.txtUline.Visible = _<br>Not CodeContextObject.txtUline.Visible<br>End Function<br><br>For this effect, just code into format event<br>=UnderlineAlternateLines()<br><br>Good Luck,<br>RDH<br><br><br><br> <p>Ricky Hicks<br><a href=mailto: rdhicks@mindspring.com> rdhicks@mindspring.com</a><br><a href= > </a><br>
Daybreak, just to clarify, the code I supplied:<br><i><br>Static Counter<br>Counter = Counter + 1<br>If Counter Mod 2 = 0 Then<br> Me.Detail.BackColor = 12632256 ' grey<br>Else<br> Me.Detail.BackColor = 16777215 ' white<br>End If<br></i><br>... is <b>not</b> for creating a new public function. The declaration shown:<br><i>Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)</i><br>is what you get if you open the OnPrint event of the report's Detail Section. Of course if you do want to use it for multiple reports as Amiel and Ricky suggest, it is better to create a new public function, then just call it from the Detail Section's OnFormat or OnPrint section of each report.
Elizabeth - the reason that using the "PrintCount" argument of the OnPrint event doesn't work in this case is that PrintCount is a count of how many times the current record has been printed. For example, if part of a record is printed on one page and the rest is printed on the next page, the Print event occurs twice, and Microsoft Access sets the PrintCount argument to 2.<br><br>Hope this clears that one up.<br><br>Jonathan
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.