Solved

Setting text color on a subform

Posted on 2001-08-17
6
436 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

911 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

17 Experts available now in Live!

Get 1:1 Help Now