Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change color ONE field in detailsection

Status
Not open for further replies.

DeSn

Programmer
Nov 20, 2001
111
BE
Hi,

I want to change the color of one field 'date'(not the whole column) when an other field 'number' (of the same record) is zero. Is this possible? I've tried it, but each time all the datefields (the whole column) have changed.

Thanks D
 
If you want to change only the color of the characters in the field, there is a walkaround.

Create a clone of your field with the same source, but with the second color of character and a transparent background.
Put this second field OVER the first; In fact, wait till everything is OK to put it exactly over. It's a little bit tricky to access them after that.

Then if the first text box put the formula:
Iif ([TextBox_number=0;[Date];"")
In the second one, the opposite:
Iif ([TextBox_number<>0;[Date];&quot;&quot;)
 
I suspect a misunderstanding somewhere. An application with the same mechanism ran for months.

Am I right when I said:

1)What you display is a Form.
2)This form shows several lines of record at a time.
3)TextBox_Number is a bound field in this form
4)The text boxes I told you are in the same form (or subform) as TextBox_Number.
5) What you expect is that the Date appears in a different color of character depending on the value of TextBox_Number but keeps the same background color.

If everything is right, could you tell me more details on the result.
 
Everything you say is correct, but somehow it doesn't work. I have a form with with in the detailsection a datefield and a numbefield next to each other. When I run the program, I get a number of records. Now I want the date to be red when the number is zero. I've followed your instructions, but all the dates become red. :(

Isn't this logic if your transparant field is also a boundfield?

D
 
Correct,Desn, whatever,
This is a recurring Access issue--due to the object-oriented-ness of it all, the continuous forms propogate the same object (textboxes, etc) for each row, whereas in Excel, each cell is it's own object--each way having it's own advantages /disadvantages.

There are numerous 'workarounds' out there, I've tried ones such Lozeres' and they work, but the downside being: how do you edit the data?

More useable solutions are far more complex, involving API calls to fill fields, etc, and that's just too much trouble for my taste. Third party grids usable in vb can do alot more than the subforms from a cell-by-cell design-property standpoint, but I don't believe they're portable to Access.

If a 'color cue' is all you need, why not use a dummy field in the table? It's blank normally, but if the date or number or whatever is at the threshold where you want to alert the user it has, say some value, say '1' or 'x', then the subform control uses symbol or marlett or other symbol-type font, with say, red color. Update the field on AfterUpdate of the dependant field. It's very simple and it 'works good enough' for most purposes.
--Jim
 
I have something similar to Lozere, but both text boxes are not bound. The real textbox (DateLastAudit) is bound. The other textbox, Txt2 (formatted transparent border and back with red forecolor)sits on top of the DateLastAudit textbox and has it's control source set to be:
Code:
-IIF(datediff(&quot;d&quot;,[DateLastAudit],Date()) > 30, [DateLastAudit],&quot;&quot;)

With this, if the DateLastAudit is more than 30 days old, Txt2 has a value and that value is the same value as DateLastAudit and that value sits on top of DateLastAudit and that value is displayed in red. If DateLAstAudit is not more than 30 days old, the value of txt2 is a zero-length string.

As to Jim's concern on editing, I set the Txt2 Tabstop property to No, set its OnGotFocus event to
Code:
   DateLastAudit.SetFocus
and on the DateLastAudit AfterUpdate,
Code:
   Txt2.Requery

This has worked fine for me, but I will admit I'm saving up for Access 2K that I hear supports conditional formatting on Continuous forms.


HTH

John

Use what you have,
Learn what you can,
Create what you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top