Solved

Setting text color on a subform

Posted on 2001-08-17
6
451 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
Technology Partners: 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!

 
LVL 58

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 58
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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

628 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