Solved

Setting text color on a subform

Posted on 2001-08-17
6
448 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

710 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