Setting colors in forms and reports
You can use the RGB function to set colors in forms and reports by using the "forecolor" and "backcolor" properties in VBA code. These colors can be conditional based on some field value. The RGB function uses the three primary colors of red, green, and blue (in that order). By adjusting the numbers, you can get up to 16 million color combinations.
As you probably know, "forecolor" is the color of the text in a textbox. You can use the "backcolor" to set the background color of a form, a report, or just about any object.
Here are some samples:
txtSales.ForeColor = RGB(255, 0, 0) 'color is red
frmStartup.BackColor = RGB(125, 125, 0) 'gray
If txtAccountBalance > 0 then
txtAccountBalance.ForeColor = RGB(0, 255, 0) 'green
End if
lblReportTitle.ForeColor = RGB(0, 0, 255) 'blue
txtUserName.ForeColor = RGB(0, 0, 0) 'black
rptMaster.BackColor = RGB(255, 255, 255) 'white
?.ForeColor = RGB(255, 125, 0) 'orange
?.ForeColor = RGB(255, 255, 0) 'yellow
?.ForeColor = RGB(255, 0, 255) 'purple