Access 2007 How to Color Selected Row in VBA

Howard Bash
Howard Bash used Ask the Experts™
on
I am looking for a snippet of code demonstrating how to set a selected row to a color.

Please advise.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

Commented:
By "row", do you mean a row in Datasheet view? If so, you'll have to use Conditional Formatting. The help topic is pretty thorough about the mechanics of this. The simplest way is to include a label or rectangle control that enclosed your entire Detail section, then set the Controls to all transparent backgrounds, then use CF to color the lable or rectangle.
Howard BashSenior Software Engineer

Author

Commented:
Yes, I mean the datasheet view.  I am not clear at all about using a label or rectangle control.  Do you mean to dynamically place a label over the selected row and set it's color?

If you could provide either a complete description, example, or reference to an example that would be great.  

Also, not sure about the Help Topic to search on ... "Color datasheet row",  "Using a label to color a row in a datasheet",...


Thanks.
Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

Commented:
You can't do that in Datasheet view (the rectangle or lable trick, that is) - I should have specified that this was for Continuous forms.

You'll have to apply formatting to each control on the Datasheet view. You'll do this in Design view - open the form in Design view, select a control, then click Format - Conditional Formatting. You can get to the help topic from there.
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

MIS Liason
Most Valuable Expert 2012
Commented:
Howard BashSenior Software Engineer

Author

Commented:
I would have preferred the solution to be in Access2007.  But as long as the same principles can be applied in 2007... thanks.
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
;-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial