Time for a quick Access formatting quiz. If you have ever tried to make a control stand out on a form, changed a color property, or pasted a color-picker value somewhere Access did not appreciate it, this one is for you. There are five questions covering ForeColor, BackColor, FontSize, and RGB color expressions.
Give yourself a few seconds to answer each question before reading the answer. No peeking. The Martians are counting on you to accidentally repaint your entire form bright red.
Question 1: Which control property changes the color of text displayed in a text box without changing its background?
A. BackColor
B. ForeColor
C. FontSize
D. Caption
Answer: B. ForeColor. The ForeColor property affects the characters inside the control. BackColor affects the area behind those characters. Think of ForeColor as the ink and BackColor as the paper. You can use both together, of course, but they do two very different jobs.
Question 2: What color does the Access expression RGB(0, 0, 255) produce?
A. Red
B. Green
C. Yellow
D. Blue
Answer: D. Blue. RGB stands for red, green, and blue, in that order. Each value can range from 0 to 255. In this case, red is zero, green is zero, and blue is cranked all the way up to 255. That gives you bright blue.
For example, RGB(255, 0, 0) is red, RGB(0, 255, 0) is green, and RGB(255, 255, 0) gives you yellow because red and green together make yellow. Once you get used to RGB, it becomes much easier than trying to remember random numeric color values.
Question 3: In a SetValue macro action, which expression is the best way to assign bright red to a text box's ForeColor property?
A. =RGB(255, 0, 0)
B. RGB(FF, 00, 00)
C. "#FF0000"
D. =Val("#FF0000")
Answer: A. =RGB(255, 0, 0). The RGB function returns the numeric color value Access needs for a color property. The equal sign tells the SetValue action that you are entering an expression to evaluate, not merely typing text into a box and hoping Access reads your mind.
Question 4: A macro should make a control's text larger when an order reaches a particular status. Which property and value should it set?
A. ForeColor to "16"
B. BackColor to 16
C. FontSize to 16
D. Caption to 16
Answer: C. FontSize to 16. FontSize is the property that controls how large the characters appear. This can be useful when you want to emphasize something important, such as a rush order, an overdue balance, or a customer who has managed to call you seventeen times before lunch.
Question 5: Why can copying a color-picker value such as #FF0000 directly into a SetValue macro expression cause an error?
A. SetValue can change only text values, not formatting properties.
B. The color picker uses hexadecimal text, while the property needs a numeric color value or a color expression.
C. ForeColor can be changed only with VBA, not macros.
D. Access requires all colors to be entered as theme names.
Answer: B. A color picker may display colors in hexadecimal notation, such as #FF0000 for red. That format is common in web design, but it is not automatically a valid Access macro expression. A property such as ForeColor expects a numeric color value, and =RGB(255, 0, 0) is usually the cleanest way to provide one.
So, how did you do? If you got all five, congratulations: the Martians did not get to repaint your database. If you missed a couple, no worries. Control formatting is one of those small Access topics that becomes very handy once you start building forms that need to communicate more than just raw data.
Watch the embedded video for the quiz version and a quick visual walkthrough of these formatting properties.
Live long and prosper,
RR