View Single Post
  #7  
Old May 12th, 2005, 05:22 PM
Tim
external usenet poster
 
Posts: n/a
Default

So I would not be able to do this by setting up a table with the condition in
one column and the color# in the second column.
I would need to specify the condition in the line of code?

This list has the potentional of expanding; what I wrote was just a
quick-and-dirty example.

Sorry I didn't clarify that before.

"Wayne Morgan" wrote:

Select Case Me.txtBox
Case "X1", "X2", "X3"
Me.txtBox.BackColor = 255
Case "Y1", "Y2"
Me.txtBox.BackColor = 100
Case "Z1"
Me.txtBox.BackColor = 301
Case "Z2"
Me.txtBox.BackColor = 302
Case Else
Me.txtBox.BackColor = 16777215
End Select

In the first statement, you may be able to get by with

Case "X1" To "X3"

so, if you have a lot more of these (i.e. X4, X5, X6, etc), that may be the
shorter way to write it. With just 3 elements though, it's not much shorter.
Whether or not this could be simplified (to lessen the typing) will depend
on how many you have and what sort of pattern they are (i.e. is there a
pattern to them that would be short and easy to code). The Like operator may
come to mind, but it's not supported in a Select Case statement.

--
Wayne Morgan
MS Access MVP


"Tim" wrote in message
...
Could this work:

Condition BackColor
X1 255
X2 255
X3 255
Y1 100
Y2 100
Z1 301
Z2 302



Would this be more efficient, espically if I have a long list, and more
conditions arise that would require highlighting?

How would I structure the VBA code?