INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to

Set Colors in Forms and Reports by randysmid
Posted: 6 Nov 02

            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

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close