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

changing back color for every alternate record in a report

Status
Not open for further replies.

rukk

Programmer
Dec 29, 2003
38
US
Hi,
I have created a Report in Ms-Access Database. I need to change the back color for every alternate record.

eg: ProductId ProductDescription DateDalivered

These are the three fields in a record, when i run a report the first recordset of the three field should have red color and the second recordset should have green color. And again the thrid record should have red color and the next one green and so on..
Is there any way to do that?
Thanks.
 
see faq703-2684

change the colors as necessary...

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Set up a counter that you increment for each detail (row). Test to see if it's odd or even and set the colors (of the detail and/or of each field) to the appropriate value. This can work with three, four, or more colors if you just allow for enough divisors.

Example:

'(at top of report)
Dim lngCount as long
lngCount = 0

'(set up as code in back of the Detail section)
intCount = intCount + 1
if int(intCount/2) = intCount/2 then
'set controls to first color here
else
'set controls to second color here
end if

 
Thank you so much for your quick response. I am kind of new to this. Can you please tell me how to set the control,like i have done

Me!Value.BackColor=vbRed

but it's not working. If you could reply to this that will be great.
Thanks.
 
Hello Robert L. Johnson III

Thank you so much for your response. It worked for me. As you said sometimes the requirement that we get is kind off crazy. Any way Thank you for solving my problem.
Thanks once again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top