Full Version: Highlighting controls in a continuous subform
UtterAccess Forums > Microsoft® Access > Access Forms
Hein
Hallo
Hope somebody can help with my next question.
On a continuous subform I have, amongst others, a control named ID (fake name)
Some of the values are re-occurring, let's say:
1
2
3
1
2
4
3
2
4
1
etc
With conditional format I can change the background color of a control when it has the focus.
Let's say a control / row with value 2 has the focus.
Is there a way to change the backcolor of every control with the value 2
If there is a way to highlight to whole row that has has the focus and all other entire rows that have the same value this would be even better!!
Thanks in advance
Hein
fkegley
You might try conditional formatting.
lso this link might be helpful:
http://www.mvps.org/access/forms/frm0047.htm
niesz
Use Conditional Formatting
ield Value Is ..... equal to .... 2
Hein
Thank you Frank (Again!!)
I have something to work on this weekend.
I will let you know if I got it working
Hein
Hein
Niesz
thanks for your respons
The value will not always be 2, but changes each time I switch rows!!
So I would like to have it more dynamic
The method Frank just posted seems to do just this (after a quick reading, I have to try it this weekend)
Hein
fkegley
Yes, I would like to know if it works.

You're welcome.
Edited by: fkegley on Fri Dec 16 16:48:48 EST 2005.
Hein
Frank
Maybe I shouldn't have put 2 questions in 1 thread, my mistake, sorry!
My main question was if it is possible to highlight every control that has the same ID as the control that has the focus. This alone would be OK if I have this. To make it even more beautiful I’ve added the second question to highlight the entire row. This, however is not as essential as the first question.
The other mistake I’ve made is to put the second question in bold letters which kind of distracted from the first question.
Anyway, I read the extra information / link you gave.
In this article it says add a control. But what kind of control? I’ve tried adding a textbox (I thought that this was the most appropriate).
After carefully doing what the article says I get no error warnings, but everything has the same color as the intended highlight color (Yellow in my case).
Another question: in the article they say to add a control with the name ctlCurrentRecordControl. In the code however they mention ctlCurrentRecord. I’ve changed ctlCurrentRecordControl to ctlCurrentRecord.
If it works I don’t know because the whole form is yellow
I would like to forget the “colouring of the entire row” and get back to the first question (only highlight control ID that has the same ID as the one that has the focus), at least for now.
Do you have any thoughts on this one?
Additional:
I’ve worked this weekend on my database and I may need to change the subform from a continuous view to datasheet view since there a more colums/controls on the form to fit in 1 window, and I need to freeze a few columns. Does this change anything?
Thanks in advance
Hein
Hein
Frank
In my previous thread I thought I might have to switch from continuous subform view to datasheet view.
Now I'm sure I have to
Maybe this changes things
Hein
fkegley
Yes, I think just plain on conditional formatting will work here.
Hein
Frank,
I've installed conditional format for the control that has the focus "many moons ago" and that works fine.
However: this is only the beginning of what I would like to have.
In my subform I have sometimes more than 200 rows.
One of the fields is ID. Often more than 1 row has the same ID, e.g.:
ID
1
2
3
1
2
4
3
2
4
1
etc
I would like that if e.g. ID value 2 has the focus, all other controls that also have the value 2 are highlighted (yellow backgound)
In conditional format I can do this only with the field that has the focus, not for its peers
What can I do?
Thanks in advance
Hein
fkegley
I have been messing with this a little, and I have concluded that it cannot be done. Access seems to always want to apply the formatting to each row of the recordset. Yes, I did write some code that seemed to work but actually, didn't. That is, I could step thru it and see that it was stopping on the correct records and doing the format, and not stopping on the "wrong" records and not doing the format, but when I looked at the form itself, it had applied the formatting to the same field in every row. The same with background color of the Detail section.
Hein
I appreciate the trouble you went through Frank! Thumbs up!
Unfortunately the answer is not what I would like to hear but sometimes you cannot get it all
opefully in the future Microsoft makes it possible, until then we just have to improvise
Again: thanks for your efforts!
Hein
fkegley
You're welcome.
niesz
Do you mean like this?
See attachment...
fkegley
Very good, niesz, that never occurred to me. That is I believe what Hein is looking for. Let's hope he sees the post.

Nice code.
Edited by: fkegley on Wed Dec 21 13:05:24 EST 2005.
niesz
Conditional Formatting.
fkegley
Yes, the answer occurred to me right after I posted. I changed my post but not fast enough, I see.
niesz
Ya gotta be quick....
fkegley
Inspired by niesz's solution to your problem, I found a slightly different solution of my own.
Hein
Gentlemen!
Luckily I looked again at my thread and found your suggestions!
It works perfectly, just what I had in mind!
It also works well in both continuous form, as in datasheet view so this option is still open for other uses.
Apparently it takes my computer some power because it takes a little while (still normally less than 2 secs) for the results to appear.
I've downloaded your last solution Frank but there doesn't seem to be any code in the database??
Where am I to look in the database, I can't find code or conditional formatting anywhere
Anyway: thanks Frank and Niesz for your contributions
Hein
niesz
Although flattered by the replication, I found that I needed to put:
e.[Orders subform].Form.Refresh
In the AfterUpdate event of your combobox to make it work.
niesz
Frank's conditional formatting is in the Customer field, turning the font to Red. See my previous post. I couldn't make it work until I added this line.
fkegley
There is no code. It is done via conditional formatting ONLY. Open the form in design view. Click the ID text box, Format--->Conditional Formatting... That is where it is.
niesz
Perhaps this is something new in 2002 (I'm using 2000) but I could not get the fields to change without issuing a Refresh.
fkegley
Yes, that could be. I have lost track of the previous versions. I am using version 2003 and no longer have access to version 2000. But if it takes a refresh to work, then so be it!
Hein
Frank, Niesz,
On the setups I've tried, using your solutions, I notice there is a subtle difference between the 2.
In the solution from Niesz, when there are, lets say, 4 rows and only 2 are visible, when I scroll up/down the remaining 2 don't change color/adjust.
In the second solution they do change when there are made visible by going up/down the rows.
Anyway: I'm happy with the results
Thanks
Hein
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.