Nigel Fowle
02-13-2001, 02:13 PM
Is it possible to change the BackColor property of a Text box depending on it's value ?
The Text box is being Continously listed in the Detail Section of a SubForm to the main Form.
pdx_man
02-13-2001, 03:42 PM
Yes
go to the properties window for the form. (Make sure it says Form in the title bar of the properties)
Select the Event tab and find the On Current line
Click on the elipses (...) button and select Code builder
Private Sub Form_Current()
If Me.Field1 > 1 Then
Me.Field1.BackColor = vbRed
Else
Me.Field1.BackColor = vbGreen
End If
End Sub
Nigel Fowle
02-13-2001, 11:44 PM
Thanks for info, but I'm using A97 and this doesn't work - it only converts all Text box formats to the first change rather than reacting to each Text box value.
I've an idea that this doesn't happen with A2K and there is some kind of fix for A97 - but what is it ?
Atomic Shrimp
02-14-2001, 12:07 AM
Access 97 doesn't have conditional formatting built-in like A2K.
I know of a way to change the ForeColor (or font style) of text boxes in a continuous form depending on their value, but this relies heavily on the back style being set to transparent, so I don't think the idea can be translated to work with the BackColor.
If you would like a copy of the forecolor demo, email me with 'A97 Conditional formatting' in the subject line and I'll attach it to the reply.
HTH
Mike
hurin
02-14-2001, 02:42 AM
You need to put your code in the on change event of the text/combo box which is changing.
ie
Private Sub InputBx_Change()
If InputBx.Value = "RED" Then
InputBx.BackColor = vbRed
Else InputBx.BackColor = vbGreen
End If
Hurin
Atomic Shrimp
02-14-2001, 03:31 AM
In a continuous form though, the text boxes in a column are iterations of the same text box object; changing the back colour of the object affects the entire column (at least it does in A97).
There is a way of highlighting the current row (see http://www.mvps.org/access/forms/frm0047.htm ), not sure if that might be able to be adapted to work for any row, not just the current one.
HTH
Mike
Atomic Shrimp
02-14-2001, 04:31 AM
SUCCESS!!
I've had a play around and my demo now includes conditional formatting of both the fore and back colours in A97, it is unbelievably fiddly to set up but worthwhile and actually gives you more flexibility than 'real' conditional formatting in A2K!!
Let me know if you would like a copy.
Mike
Nigel Fowle
02-14-2001, 04:55 AM
To Mike G - From earlier replies and searching for info I've got it working in ForeColor no probs - by using an overlayed second Text box set to a different color from the first Text box - I found that using Blue and Red worked fine with a logic test in the Event of the second Text box.
I would really like to change the BackColor and if you've managed that I be grateful for the code.
I did e-mail you previously but I'm not sure it was correctly addressed.
My e-mail addrs is
Nigel.Fowle-Fowle.Co@btinternet.com
Thanks a lot.
Atomic Shrimp
02-14-2001, 02:21 PM
On the offchance that anyone else would like the demo of what I am now calling 'Access 97 Pseudo Conditional Formatting' , I've posted a copy here:
http://www.eat-it.freeserve.co.uk/MDB/Pseudo.zip
Mike
softpro
11-01-2001, 10:40 AM
I am in the same boat now.
Did any of you find a way to change the text box background color in the continuous forms. I could change the fore color with this logic. I want to change the background color explicitly depending on the text box content.
Please throw any information regarding this.
Thankz a lot!