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

CHANGE ROW COLOURS IN DATASHEET 4

Status
Not open for further replies.

barry2004

Technical User
Oct 13, 2004
42
GB
Hi guys, this question has been asked in various guises but not in this manner. Are there ways of changing the colours of all the rows whose ID numbers are either Odd or even? E.g. rows with record ID's 1,3,5,7,9,11 etc. would have a different colour to the even numbered rows which would remain in the default colour.
 
Barry, changing the backcolor of the detail section or textboxes in design view of a form that is displayed in datasheet view has no impact on the view so I'd guess there's really no way to manage that.

You could create a continuous form, that looks like a datasheet view for that and use conditional formatting.

HTH

John

Use what you have,
Learn what you can,
Create what you need.
 
How are ya barry2004 . . .

If you have 2k or higher, hav a look at [blue]Conditional Formatting![/blue]

Calvin.gif
See Ya! . . . . . .
 
Hi guys, trust me i have tried everything one can think of. Not even conditional formatting has the above mentioned capabilities.
 
barry2004 said:
[blue]Hi guys, trust me i have tried everything one can think of. [purple]Not even conditional formatting has the above mentioned capabilities.[/purple][/blue]
Really! . . . then how is it I have DB's using conditional formatting to perform exactly what you've asked (a number of clients who requested alternately colored records) . . . despite the fact that I ran a simulation before posting?

I don't know what you attempted, but apparently it wasn't right. Perhaps if you post what you tried with conditional formatting?



Calvin.gif
See Ya! . . . . . .
 
AceMan,

I really want to do this. If you wouldn't mind letting me know how. Thanks!

 
There are at least two ways, off the top of my head (that should probably work) ...

1 - create a calculated control wich uses the id numbers (mod 2 stuff), then base the conditional formatting on that.

2 - create this calculation in the underlying query (this may have consequences on updateability)

Use "expression is" and use something like

[tt][MyCalcControlOrField]=1[/tt]

as expression, format and ...

Re 1 - remember consequences, like described here Conditional formatting flaws

To make the whole section formatted (in a continuous form), you may consider using a large text control to place behind the rest of the controls, set the rest of the controls back style to transparent

Roy-Vidar
 
From the post origination:
barry2004 said:
[blue]Are there ways of changing the colours of all the rows whose ID numbers are either Odd or even? E.g. rows with record ID's 1,3,5,7,9,11 etc.[/blue]

Bear in mind, conditional formatting can only control [blue]comboboxes[/blue] and [blue]textboxes[/blue]. Also, as shown by [blue]RoyVidar's[/blue] link, be careful of [blue]calculated controls[/blue] included in your format condition.

Copy the following expression:
Code:
[blue][YourIDFieldName] Mod 2 <> 0[/blue]
Open the form in designview.

Then for each textbox/combobox you wish to change color in a record for odd IDs:
[ol][li][blue]Select[/blue] the control.[/li]
[li]MenuBar - Format - [blue]Conditional Formatting...[/blue][/li]
[li]In the combobox select [blue]Expression Is[/blue][/li]
[li]In the field next to the combobox [blue]paste the expression.[/blue][/li]
[li]Select the [blue]background/foreground[/blue] colors you desire & click ok.[/li][/ol]

[blue]RoyVidars[/blue] has also provided a good method for coloring a complete section.

[purple]Cheers! . . .[/purple]

Calvin.gif
See Ya! . . . . . .
 
Thanks all of you and for those who have benefited from this post all the better. I had already used the Mod 2 <> 0 control ages ago but was only able to get the specific field formatted. Will take what RoyVidar said into consideration. I really had no significant need for it, was more for asthetic looks than anything else.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top