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

Continuous forms record color 1

Status
Not open for further replies.

kwor

MIS
Dec 10, 2008
35
AU

I have a table with two fields: category and color.
The color field stores a user selected number according to a color, e.g. 39423, 52479, 16763904, etc.

I wish to create a form/report as a legend to a graph. The legend will display the category text and a control next to it showing the respective color - i.e. change the background color to the value of the color field corresponding to the category.

Since users can update categories and colors, I cannot make a fixed form, it must be dynamic, i.e. a continuous form.

Any suggestions will be appreciated.
 
With a contionous you could do this up to three colors using conditional formatting. More than that you can not.

Do you know a max amount of colors? Lets say it is 10. Then I would set my footer up like

lbl1 textBox1 lbl6 textBox6
lbl2 textBox2 ...
lbl3 textBox3 ...
lbl4 textBox4 ...
lbl5 textBox5 lbl10 textBox10


Then read through the table. If there is seven values. Show the first seven hide the last three. Set lbl1 to the first category, set the background of textbox1 to the background for category 1.

This could be done with a label to save space. And set the caption to the category and the background to the color. (You will have to check with black on black)


I strongly discourage trying to add controls dynamically. Unless you are a very good coder this will get you in trouble. Access is really not well designed for adding controls dynamically. I would think with the above design you could easily have 20 controls to show/hide.
 
Thanks.
It's not exactly what I was looking for but it's a good fallback solution.
 
It's not exactly what I was looking for but it's a good fallback solution
I think this is the best you will do. Any other approach will take extremely complicated API coding. Can not be done with a native continous form.

Here is your best solution. This is actually really slick and simple to do. You can add, change and delete records and see the legend update

 
Here is an update.

Noticed that you said report as well. A continous report is very simple. If you bring it up in print preview you can simply do something like

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Me.txtBxColor.BackColor = Me!lngColor
Me.txtBxColor.ForeColor = Me.lngColor
End Sub

where lngColor is your field with color codes.
 
Thanks MajP

There is enough information there for me to design what I need. Not what I envisaged at first but one must be adaptable.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top