Quickie !  Making a variable colored label...

Posted on 2011-10-24
Medium Priority
Last Modified: 2012-05-12

Hi again,
see this line below.
Me.ReportedByID.BackColor = vbRed

Instead of vbRed I want to be able to have a variable.
So, for instance, I want to be able to set of fields to a different colour without have to amend multiple fields.   How do I do this??
Question by:Patrick O'Dea
  • 3
  • 2
LVL 61

Accepted Solution

mbizup earned 2000 total points
ID: 37016970
Not  100% clear.  Do you mean that you want a different color in different circumstances?

If so you could do something like this, placed in a public module given a name like modFunctions (or anything other than 'ChangeCtlColor')

Sub ChangeCtlColor(ctl as Control, newcolor)
      ctl.BackColor = newcolor
End Sub

Open in new window

You'd call it like this

ChangeCtlColor Me.ReportedByID, vbBlue

Open in new window

LVL 49

Expert Comment

by:Dale Fye
ID: 37017278
I prefer to use conditional formatting.
LVL 61

Expert Comment

ID: 37017329
Th OP is asking about a label.

I guess it could be changed it to a textbox with properties to make it look like a label in order to use CF.
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

LVL 49

Expert Comment

by:Dale Fye
ID: 37017349
Was not sure, the title says "label", but then in the text, the OP used fields.  Thought I'd throw our that option too.

LVL 61

Expert Comment

ID: 37017367
Yeah... either way, its a good option.

Author Closing Comment

by:Patrick O'Dea
ID: 37017459
Thanks, that works nicely.

(I DID mean "label" .... excuse my lack of correct terminology ... I am a victim of being self taught by a lazy teacher !!)

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question