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

Change Font Color in Code

Status
Not open for further replies.

risoam

MIS
Apr 17, 2002
33
US
Hi. I am tying to change the font color of each row on my report. I can't use the conditional formatting because of the Access version. I have one field of data that is my record per row and it spans the entire field. When I right click it and go to properties, I don't have an OnFormat option. How come I can't, or how can I change the font color? As far as the colors, if there was even a counter that each record got a different color that would be fine.

Thanks.
 
Don't remeber who in this group posted this but here is some code that makes the report have every other line shaded...like an inventory list. If it placed in the Details.OnFormat property in your report. You can modify it to fit your needs. Good luck and let me know if you need some help.

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

Const cLightGrey = 12632256
Const cWhite = 16777215

If Me.Detail.BackColor = cWhite Then
Me.Detail.BackColor = cLightGrey
Else
Me.Detail.BackColor = cWhite
End If

End Sub There is no I in team.

Robert L. Johnson III, A+, Network+, MCP
robert.l.johnson.iii@citi.com
 
I did actually see that but I am more trying to change the font color and when I substituted forecolor with backcolor it dodn't work. Thanks though.
 
Bob's example shades the background of each detail row. You can adopt it to change the forecolor of each CONTROL in the row. It's just a bit more code:


If me.TextBox1.Forecolor = vbBlack then
me!TextBox1.Forecolor = vbRED else
me!TextBox1.Forecolor = vbBlack
end if

Something like that for EACH control that you want to alter the foreground (font) color for should work for you. Just substitute your control names for "textbox1", obviously.

Jim







There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
I see how that will work but where do I put that code. I do not have any event options when I click properties on my control. It is not a textbox that I can type in to. It is on a report that is bound to a table. Thanks.
 
In design mode of the report, right-click on the background of the details section. Select properties. In this pop-up box, there is a proprty called OnFormt. If you left-click on the very right end of this box, a little arrow button will appear. This opens a drop down list. Select Event Procedure from this ;ist. Then, just to the right of this box is an elipse button (three small dots in a button). Click this and the VBA code window will appear. Put the code here between the Private Sub and End Sub Lines. When the form is open, it uses any code here to format the details of the report. There is no I in team.

Robert L. Johnson III, A+, Network+, MCP
robert.l.johnson.iii@citi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top