UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Combobox Change Row Text Color, Access 2016    
 
   
tobyhanna
post Apr 21 2017, 12:29 PM
Post#1



Posts: 99
Joined: 7-February 06



Hello,

I have a form with a combobox which is filled with data from a table, tblItem, and is based upon another combobox's value (tblCategory).

tblIten has a few fields, namely "Preferred" which is a T/F (checkbox) field. I want to do two things in the comobobox that lists the values from tlbItem.

(1) sort the comobobox with the Preferred=T records at the top, then by a Description - this I have accomplished
(2) color code the font/text/ForeColor of the Preferred=T records to Bolded Green (all other records, Preferred=F, remain black) - it seems this is not possible but I thought I'd ask - perhaps in a new version?

I tried Conditional Formatting but this changes every row, I'm looking for a one by one row color change within the combobox control based upon a value within the combobox's recordsource.

Thank you for your help,
Liesl
Go to the top of the page
 
GroverParkGeorge
post Apr 21 2017, 12:46 PM
Post#2


UA Admin
Posts: 29,161
Joined: 20-June 02
From: Newcastle, WA


Unfortunately, there's no native way to change font or highlight colors in combo or list boxes. You might find custom code because there are some very clever developers out there, but it will definitely not be an easy thing to do.

That said, maybe a second control could be placed above or to the side of the combo box to hold the Preferred selection. It could be highlighted as you wish.

--------------------
Go to the top of the page
 
Doug Steele
post Apr 21 2017, 12:46 PM
Post#3


UtterAccess VIP
Posts: 21,058
Joined: 8-January 07
From: St. Catharines, ON (Canada)


You're saying you want the list in the combo box to have different colours? That's not possible with any version of Access.

I believe there may have been a third-party at one time that was capable of doing this, but I've lost the details I'm afraid.

--------------------
Go to the top of the page
 
GroverParkGeorge
post Apr 21 2017, 12:49 PM
Post#4


UA Admin
Posts: 29,161
Joined: 20-June 02
From: Newcastle, WA


Another thing I've done (and seen done by others), is to concatenate something into the display value to indicate status.

Something like this: Iif([Status] = "Inactive", "(I)" & [DisplayName], [DisplayName])

--------------------
Go to the top of the page
 
GroverParkGeorge
post Apr 21 2017, 12:49 PM
Post#5


UA Admin
Posts: 29,161
Joined: 20-June 02
From: Newcastle, WA


yeah, I was thinking Stephen Lebans might have done something like that?
This post has been edited by GroverParkGeorge: Apr 21 2017, 12:53 PM
Reason for edit: Autocorrect strikes again

--------------------
Go to the top of the page
 
tobyhanna
post Apr 21 2017, 01:11 PM
Post#6



Posts: 99
Joined: 7-February 06



Thank you for the quick responses. I saw a few involved work arounds. I do like the concatenated idea you posted, may give that a try.

Thanks,
Liesl
Go to the top of the page
 
GroverParkGeorge
post Apr 21 2017, 01:27 PM
Post#7


UA Admin
Posts: 29,161
Joined: 20-June 02
From: Newcastle, WA


Screenshot of one implementation in one of my dbs.

Attached File  2017_04_21_11_23_45.png ( 3.18K )Number of downloads: 8


I concatenated in * instead of (), but otherwise the same idea.

--------------------
Go to the top of the page
 
Peter Hibbs
post Apr 21 2017, 04:50 PM
Post#8


UtterAccess VIP
Posts: 1,391
Joined: 17-June 10
From: Dorset. UK.


Hi Liesl,

Perhaps this Combo Box Demo in the UA Archive will do what you want.

Peter Hibbs.
Go to the top of the page
 
GroverParkGeorge
post Apr 21 2017, 04:55 PM
Post#9


UA Admin
Posts: 29,161
Joined: 20-June 02
From: Newcastle, WA


Thanks, Peter. I shoulda searched the archives. blush.gif

--------------------
Go to the top of the page
 
tina t
post Apr 21 2017, 10:46 PM
Post#10



Posts: 4,841
Joined: 11-November 10
From: SoCal, USA


hello Peter, i downloaded your demo - cool stuff (of course)! since you're using a form to mimic the combo droplist, i'm wondering if the "change row backcolor in ContinuousFormsView" solution could be incorporated, to make each entire row colored... i can't remember where i got the solution - i definitely didn't come up with it! - and i can't post details right now because it's been several years since i last built a form using it. but i remember it involved a table of colors, stored as BMP files (the only time i've ever stored files in a table, using OLE Object data type)...hmmm, and a bound object frame control (i think) in the form's Detail section.

the form i built is still in use in an active db, at my job...if you're interested...?

tina

--------------------
"you can't take the sky from me"
Go to the top of the page
 
Peter Hibbs
post Apr 22 2017, 03:22 AM
Post#11


UtterAccess VIP
Posts: 1,391
Joined: 17-June 10
From: Dorset. UK.


Hi tina,

Would the 'solution' you are referring to be THIS ONE by any chance?

There are a few limitations with the Combo Box demo which I suspect will not make it suitable for the OP. The main one is that the drop down list box is restricted to about 10 or so rows because, with the method I used, there is no option to provide scroll bars and I am guessing that the OP will need more than 10 rows.
Another limitation is that the demo uses a SubForm control to hold the temporary drop down list and the problem with that is that a SubForm control cannot overlap the edge of the form on which it is placed. So if the user needs to position the Combo Box control near the edge of the parent form the drop down list will not show up in the correct position if it is near the edge of the form.
Another 'minor' limitation is that this version does not allow the text color to be changed (which is what the OP wanted) because it uses a separate label control to provide the color information.

I have been thinking for some time that it might be possible to use a separate 'pop-up' form as the drop down list (rather than a SubForm control) and formatted as a Continuous type form which would then allow multiple rows and Conditional Formatting could be used to color the text, back color, bold, italics, whatever. Also, this method would get round the problem of the form overlapping the edges of the parent form. The form could be positioned below the Combo Box control in the same way as I do the SubForm method and I have already posted a demo which shows how to do this for a pop-up calendar form HERE.

The main problem with this method is that I have not found any way to close the pop-up form, if the user does not want to select an item on the form, and so clicks anywhere else on the parent form to close the drop down list (as it does for the standard Access Combo Box control). For the pop-up calendar I provided a 'close' button on the pop-up form which works pretty well but I am not sure if this would be practical for a Combo box. If anyone knows of a way to detect if the user clicks the mouse anywhere on a form apart from the form that currently has the focus, then I would be interested to hear about it (and it is not as easy as it sounds).

Unfortunately I don't have much time to spend on this at the moment as I am involved in another large database project but if anyone else would like to provide some input then I am sure it will be useful for other developers.

Peter Hibbs.
Go to the top of the page
 
tina t
post Apr 22 2017, 05:42 PM
Post#12



Posts: 4,841
Joined: 11-November 10
From: SoCal, USA


QUOTE
Hi tina,

Would the 'solution' you are referring to be THIS ONE by any chance?

LOL - that's the one! with my responding post, no less! so that solves the little puzzle of where i got it, and my thanks remain, six years later, as i have used the solution in a number of forms in the databases i've written for my job. we're still using A97, if you can believe that, and those dbs are still chugging along, even in our current Windows7, Office365 environment. i keep expecting the bottom to fall out anytime now, frankly, but am not in a position to do anything about it. anyway, thanks again, Peter! :) tina

--------------------
"you can't take the sky from me"
Go to the top of the page
 
tina t
post Apr 22 2017, 06:09 PM
Post#13



Posts: 4,841
Joined: 11-November 10
From: SoCal, USA


QUOTE
I have been thinking for some time that it might be possible to use a separate 'pop-up' form as the drop down list (rather than a SubForm control) and formatted as a Continuous type form...

The main problem with this method is that I have not found any way to close the pop-up form, if the user does not want to select an item on the form, and so clicks anywhere else on the parent form

hello Peter, i just did a couple quick tests in A2003. i couldn't get anything to work, when the 'pop-up' form actually has its' Popup property set to True. but if that property is set to False, then you can use the "parent" form's OnActivate event property to run a close action on the "child" form.

i think that would work okay if the environment were tightly controlled - that is, if there is nowhere for the user to click "away" from the child form, except somewhere on the parent form. but if multiple forms can be open, it'd be trickier to prime each possible target form's Activate event, and check to see if that particular child form were loaded, and if so, close it.

hmm, anyway, just some thoughts. tina

--------------------
"you can't take the sky from me"
Go to the top of the page
 
Peter Hibbs
post Apr 23 2017, 05:59 AM
Post#14


UtterAccess VIP
Posts: 1,391
Joined: 17-June 10
From: Dorset. UK.


Hi tina,

I have tried your suggestion of using the On Activate event on my Calendar pop-up demo (which uses a separate form for the calendar rather than a Subform control) and it seems to work very well. As you say, it does not work if the user moves the focus to another form but by adding a Close Form command to the On Activate event for any other form that could be open, that solves that problem. Of course, there is still the problem that the pop-up form does not close if the user moves the focus to another application on the PC but I don't think that would be a major issue for most users.

There is also another issue (where the PopUp and Modal properties of the form are set to No) in that the form appears in a different position on the parent form but hopefully that can be solved by changing the VBA code. I think I will have a go at rewriting the Combo Box demo to use a separate Continuous type form as the drop down box which should provide more facilities for the user but it will not be for a while as I have other things to do first.

Anyway, thanks for the helpful suggestions.

Peter.
Go to the top of the page
 
tina t
post Apr 23 2017, 12:07 PM
Post#15



Posts: 4,841
Joined: 11-November 10
From: SoCal, USA


you're very welcome, Peter, glad i could contribute a little. :) tina

--------------------
"you can't take the sky from me"
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    30th April 2017 - 11:45 AM