Hello. I am trying to grey out a list box.
Me.cmdButton.forecolor = RGB(160, 160, 160) works for a command button but does not seem to work for a list box.
I would appreciate any help on how to do this
Hello. I am trying to grey out a list box.
Me.cmdButton.forecolor = RGB(160, 160, 160) works for a command button but does not seem to work for a list box.
I would appreciate any help on how to do this
Hello. I meant to shade the fore-colour grey.
It also works for a listbox
Put the following code in Form_Load event
OR just assign a colour in the property sheet for the listbox using the colour selectorCode:Me.Listbox.Forecolor=RGB(160,160,160)
It will be shown in HEX format e.g. #A5A5A5 or as a theme colour Background 1, Darker 25%
You can't use RGB notation there
Thanks. I tried putting Me.Listbox.Forecolor=RGB(160,160,160) in my code but it doesn't change anything and I don't know why. I need to do this in code and not in the property sheet.
Correct - do it in code as I described - obviously use the correct name for your listbox!!!!
OR use the property sheet as I described
Thanks again for replying. Yes I did exactly as written above but with the correct name for the listbox. I believe that this does method doesn't work with a list box. Have you tried it?
I would appreciate if anyone could suggest a solution.
Yes I've tried both methods and both work
In fact you can do a lot more than that with listboxes
This is an example of what is possible (though not necessarily desirable!)
See https://www.access-programmers.co.uk...12&postcount=3 for more info and an example database
Thanks again for replying. I have tested this issue again in 2 separate databases.
It seems that Me.Listbox.Forecolor=RGB(160,160,160) will not work for the 1st visible column in the listbox but does work for all other listbox columns.
so I still believe there is a problem here.
Thanks for sending the example db. I can see that you are right and that it is a problem in my db. I cant figure out what the problem is at the moment. Actually the listbox column header is greying out but not the values. If I get time I will try to replicate the problem in a sample db. Many thanks again.
Hello, I have a attached an example db that replicates my problem. When you click the top list box the after update property runs a query to populate the bottom list box. I include the line Me.lstWorkspaces.ForeColor = RGB(160, 160, 160) but you will see that only the header is greyed out. I would appreciate if you can shed light on this problem.
Hi
I can replicate your problem but i can't see what's causing it - I've tried changing the theme, creating a new form, decompiling & importing to a new database. None fixed it.
I can only assume there is something obscure in your settings causing this but I can't see what it is
What I can tell you is that you only need to set the row source for each listbox ONCE.
As you've set both in the form design any additional code is pointless
So everything in GREEN below should be removed
However that doesn't fix this issueCode:Option Compare Database Option Explicit '<== ALWAYS ADD THIS 'Private Sub Form_Open(Cancel As Integer) 'Me.lstReports.RowSource = "qryReports" 'Me.lstReports.RowSourceType = "Table/Query" 'End Sub 'Private Sub cmdPreview_Click() 'Me.lstReports.RowSource = "qrySelectReports" 'Me.lstReports.RowSourceType = "Table/Query" 'End Sub Private Sub lstReports_AfterUpdate() 'Me.lstWorkspaces.RowSource = "qryReportWorkspace" 'Me.lstWorkspaces.RowSourceType = "Table/Query" ' Me.lstWorkspaces.ForeColor = RGB(160, 160, 160) 'NOT NEEDED IF SET IN FORM DESIGN Me.lstWorkspaces.Requery End Sub
Aside from any other issue that was raised, you have set a format on the table field. Try removing it.
Don't understand why you'd have such a format when there's only one placeholder.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.