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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create colored text 1

Status
Not open for further replies.

BSman

Programmer
Apr 16, 2002
718
US
I want to create a continuous form where a control displays either red or green blocks (or text) depending upon the value of a column in the form's data source.

Setting the control's property like background to a color based on the value doesn't work because that property for all displayed controls is changed, not just the one displaying the specific record.

An image also won't work for the same reason...you are changing the property of the control.

What I think might work is if I can put "text" (ASCII characters) into a text box that somehow include their color, but I can't figure out how to create the text strings. All I need at this time is red text and black text.

Anyone have a clue how to do this or if it's even possible?

The reason I want to do this is to create a form that displays the status of various locations and allows the user to click on a location to bring up a pop up form to change the status. Since you can't make a clickable control on a report (where the colors work fine) and I haven't been able to display the different colors on the form, I can't get a solution. (This is replacing a problematic VB application...and VB does enable creation of a form that works this way.)
 
Have you tried conditional formatting. I was trying the same type of thing for reports and found conditional formatting. It works wonders.

Select the control you want to color. Select Format/Conditional Formatting and specify the value and formatting you wish.

Tammy Thank you for your help.

Tammy
 
I did something similar to this, using a code sample I found.

Basically, you create a text box. You set the font to some font that has a solid box as one of the characters (you may need to use Character Map to find the character you want).

Then, in the control source for that box, use an Iif condition that displays a number of the character you want (from above) if a condition is true, and a blank if it is false.

I think the code is on AccessWeb -- I don't explain it very well. It works for us, anyhow.

-- Judy
 
Tammy,

I started with Access 97, but thought that maybe what you mention is a new property in Access 2000 (which I also have), so I tried it there. Lo and behold, there it is!

Thank you. I never would have looked at the format menu even in Access 2000.

You've earned a star!

Judy,

This is what I was trying to do, but the colors are a must, so I needed the same "text" but of different colors (not black and white), and I couldn't figure out how to set the color of the text without changing a property setting (with the result that all displayed records have that control changed to the one color.

 
OK, I still think you could do this. How about this option:

Let's say, for example, you have three fields: [BoundField], which is bound to the field in your data table/query, [ColoredText1], and [ColoredText2], and that if [BoundField] is less than 0, you want it displayed in Red text, and if not, displayed in green text.

[BoundField] should have its Visible property set to No. The Font Color for [ColoredText1] would be Red. The Font Color for [ColoredText2] would be Green. BackStyle for both would be Transparent.

ControlSource for [ColoredText1] would be &quot;=Iif ([BoundField]<0, [BoundField],&quot;&quot;)&quot;

ControlSource for [ColoredText2] would be &quot;Iif ([BoundField]>=0, [BoundField],&quot;&quot;)&quot;

Now, if my logic is working, it should display either ColoredText1 or ColoredText2, depending upon the value in BoundField.

Give that a try and let me know if it works (I've never tried it before, but I think this is how it should work).

-- Judy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top