Solved

Setting text color on a subform

Posted on 2001-08-17
6
433 Views
Last Modified: 2012-06-22
Hi,


i have a subform (with it's query) in datasheet mode. This subform displays some numeric and some non-numeric values. How can i set the text color of an entire row to i.e. red if a certain numeric field is negative? I tried with the Format function and with some VBA code (setting the ForeColor property) but with no results. Any suggestions ?
0
Comment
Question by:mario_34
6 Comments
 
LVL 9

Expert Comment

by:Volibrawl
ID: 6399789
Sorry,  you CANNOT do what you have asked using a datasheet form.

Check this link for some discussion and solutions for continuous subforms (but not datasheet).

http://www.mvps.org/access/forms/frm0047.htm
0
 
LVL 9

Expert Comment

by:Volibrawl
ID: 6399790
Sorry,  you CANNOT do what you have asked using a datasheet form.

Check this link for some discussion and solutions for continuous subforms (but not datasheet).

http://www.mvps.org/access/forms/frm0047.htm
0
 
LVL 54

Expert Comment

by:nico5038
ID: 6399914
As stated above, marking a whole line can only be achieved in multiple form mode and not in datasheet mode...

If you have A2000 then you can use "Tools/Conditional formatting" on the field itself.
If you set the backgrounds of all other fields to Transparant, you can "expand" the "condition field" to be as wide as the whole line. (Using left/centre/right you can place the field content accordingly)
Now just place the field <0 condition to fill the background of your amount field...

For A97 stick to the above link.

Nic;o)
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 100 total points
ID: 6400557
I have a slightly different technique that works well.

First, you'll need a "color Table".  This is a table that contains one record per color that you want displayed.

tblColor
ColorID - PK autonumber
Description - Text
ColorBitMap - OLE

  The ColorBitMap field is filled by opening the table, and doing an insert of a MS Paint object.  In MS Paint, create a 16 x 16 pixel bitmap filled with the color you want.

Next you'll either need to add a "ColorID" field to your table or use a linking table (if multi-user, you will need to go the linking table route).

tblXXXXColorLink
ID - PK - PK from original table
ColorID - PK - ColorID to display.

Now in the query that the form is based on (or make one if you need to), join the original table, the linking table, and tblColor.

 In your form, set all existing controls background to transparent.  Now add a bound OLE control and size it to fit across whatever area you want highlited (it can be the whole record area).  Bind it to ColorBitMap, set it's size mode to Strech, and move it behind all other controls by using Format/Move to back.

That's it!  You can now control the color for each record based on colorID.  ColorID can be changed on the as needed based on any condition and you can use any number of colors that you want.

You can also use multiple colors for each row just by extending the linking table with more color fields.  Performance is suprisingly good. The only real drawback is populating the linking table.  There are different ways of handling that, but for anything under a 1,000 records or so I don't think you need to bother.

Let me know if you have any questions.
Jim.
0
 

Author Comment

by:mario_34
ID: 6400777
Hi Jim,

the technique you described works only on continuous forms or does it also work in datasheet view ?
0
 
LVL 57
ID: 6400870
Just continuous forms.  Not much you can do with a datasheet.  Should have made that clearer.  

Sorry,
Jim.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now