Link to home
Create AccountLog in
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?
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

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.
User generated imageDatabase9.accdb
Avatar of philkryder
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
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Also with that technique, it doesn't have to be a color.  It can be a graphic or whatever.  

Jim.
OK, so I misunderstood your request.

I am sure what Jim posted will get you sorted...
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...
<<I tried opening the MDB with office 365/2016 and couldn't.>>


Sorry, here's a version in A2010 format.

Jim.
ContinuousFormColors_A2010.accdb
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
thanks all.
I hope to do some testing this weekend.
Phil
sorry - didn't get the time to try this.
No rush....

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