Avatar of philkryder
philkryder
 asked on

MS ACCESS 2010 ? VBA code to pull the background color from one field in a table and apply it to a row in an MS ACCESS FORM?

We would like to highlight a row in an MS ACCESS form based on a value in a column.
We'd like to keep the background color in a separate table and use the value in the form column to look up the corresponding background color and then apply it to all the rows that are in the form that have the corresponding value in the specified column.

? how do we do that?
Microsoft AccessVBA

Avatar of undefined
Last Comment
philkryder

8/22/2022 - Mon
Jeffrey Coachman

I think conditional formatting will do what you are asking...
Create a continuous view form.
Move all the control close to each other, so that they touch on all sides.
In design view, ...select all the controls on the detail section (The "Row"), while holding down the Shift key.
Then click: Format-->Conditional formatting
Click: New Rule
Enter something like:    Expression is [YourField]=3
Then set the Background color to whatever you like.
Click Apply, ...then click OK
Save the form
Re-open the form

Simple screenshot and sample DB attached.
conditional formattingDatabase9.accdb
philkryder

ASKER
yes,
but,
we want to dynamically be able to change the colors via a table  field that corresponds to the field matching the value. We do not want to be locked in ahead of time by pre-selecting a color in the UI. ? kapish ?
ASKER CERTIFIED SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jim Dettman (EE MVE)

Also with that technique, it doesn't have to be a color.  It can be a graphic or whatever.  

Jim.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Jeffrey Coachman

OK, so I misunderstood your request.

I am sure what Jim posted will get you sorted...
philkryder

ASKER
Jim - thanks for that.
Interestingly,
I tried opening the MDB with office 365/2016 and couldn't.
I'll try with a copy of 2010...
Jim Dettman (EE MVE)

<<I tried opening the MDB with office 365/2016 and couldn't.>>


Sorry, here's a version in A2010 format.

Jim.
ContinuousFormColors_A2010.accdb
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Helen Feddema

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
philkryder

ASKER
thanks all.
I hope to do some testing this weekend.
Phil
philkryder

ASKER
sorry - didn't get the time to try this.
Jim Dettman (EE MVE)

No rush....

Jim.
Your help has saved me hundreds of hours of internet surfing.
fblack61
philkryder

ASKER
sorry - I haven't had time to test the various solutions. we just lost a staff member. Phil