Change the color of a line on a form via VB

  • Thread starter Bill (Unique as my name)
  • Start date
B

Bill (Unique as my name)

I can change the color of text in a box based on the value in another
field. Why not lines? How do I do it? Is it possible? The VB code
below does not work. I get no error messages. I get nothing. I want
something, oh, so badly.

If Combo48 = "144" Then
[Line62].BorderColor = 0
End If

Thanks in advance!
 
M

missinglinq via AccessMonster.com

You can, but you have to assign an appropriate value to it! Zero is not an
appropriate value! If you replace the zero with, say vbRed, the line will
turn red!
I can change the color of text in a box based on the value in another
field. Why not lines? How do I do it? Is it possible? The VB code
below does not work. I get no error messages. I get nothing. I want
something, oh, so badly.

If Combo48 = "144" Then
[Line62].BorderColor = 0
End If

Thanks in advance!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
F

fredg

I can change the color of text in a box based on the value in another
field. Why not lines? How do I do it? Is it possible? The VB code
below does not work. I get no error messages. I get nothing. I want
something, oh, so badly.

If Combo48 = "144" Then
[Line62].BorderColor = 0
End If

Thanks in advance!

1) Where did you place the code?
Place it in the form's Current event AND in the combo AfterUpdate
event.

2) Is the Bound Column of the combo box a Number datatype or text?
If it is Number datatype then do not surround the value with quotes:
If Combo48 = 144 Then

3) If your code changes the color for a criteria value, you must then
change it back when the criteria is not met:

If Combo48 = "144" Then
[Line62].BorderColor = 0
Else
[Line62].BorderColor = vbBlue
End If
 
F

fredg

You can, but you have to assign an appropriate value to it! Zero is not an
appropriate value! If you replace the zero with, say vbRed, the line will
turn red!
I can change the color of text in a box based on the value in another
field. Why not lines? How do I do it? Is it possible? The VB code
below does not work. I get no error messages. I get nothing. I want
something, oh, so badly.

If Combo48 = "144" Then
[Line62].BorderColor = 0
End If

Thanks in advance!

Actually 0 is an appropriate value.
0 = Black (vbBlack)

The posters problem is either in his using "144" as a criteria instead
of 144 (without quotes) or in not turning the original line color back
on when the criteria is not met, or in not placing his code in the
Combo AfterUpdate AND in the Form Current event (he gives no
indication of where the code was placed).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top