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
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.