Format listbox

systemx

Registered User.
Local time
Today, 19:04
Joined
Mar 28, 2006
Messages
107
Hi all,

Hopefully a simple question.

I have a listbox on my form which is based on a query. For each row in the listbox that meets specified criteria, I would like to format the row (make font italic and forecolor red).

Code:
Dim i As Integer
Dim intCount As Integer

i = 0
intCount = Me.lstResults.ListCount

Do
i = i + 1
    
If Me.lstResults.Column(12, i) = "Completed" Then
            
'Format listbox row
Me.lstresults.Forecolor = RGB (255,0,0)
Me.lstresults.Italic = True
    
Else

If i > intCount Then
Exit Do            
End If
End If

Loop

I need to get this to work on individual rows, not the whole listbox! Any ideas?

Thanks,

Rob
 
Last edited:
Systemx,

To the best of my knowledge, the Access ListBoxes do not support different
formatting for each row. There are some third-party controls, but I have no
experience with them.

I can suggest that you display the data with a form/subform. That way you
can use Conditional Formatting to achieve the desired effect(s).

Wayne
 
That is correct that the ListBox control in VBA doesn't support individual entry formatting -- you're formatting the whole thing each time. (VB will handle this, not VBA.) You may want to consider a toggle button that switches between all the entries in your listbox and then those you wanted to turn red/italic. With the toggle button, you could easily allow the user to see all the selections and just those selections that met your criteria without using another form (or another listbox), thereby saving screen realty. I know that, as programmers, we all run at a minimum of 1280x1024, especially when programming, but there are still users that use 800x600, even on larger 17"+ monitors. Some habits are hard to change, but getting users to stop pretending to be blind is one of the hardest parts of interface design. :)
 
Thank you both. I am hesitate to do away with the listbox - but will come up with another method of making the information clearly visible. Will probably just run with a checkbox on the form to filter the information or something along those lines.

Unfortunately, most of the users here are on 1024x768 on 15" monitors....a real pain especially when trying to make lots of info available on the one form - hence lots of use of tabbed forms :)

Cheers,

Rob
 
Hi,

Else try

http://www.lebans.com/toc.htm

Look for ConditionalFormating

or here


systemx said:
Thank you both. I am hesitate to do away with the listbox - but will come up with another method of making the information clearly visible. Will probably just run with a checkbox on the form to filter the information or something along those lines.

Unfortunately, most of the users here are on 1024x768 on 15" monitors....a real pain especially when trying to make lots of info available on the one form - hence lots of use of tabbed forms :)

Cheers,

Rob
 

Users who are viewing this thread

Back
Top Bottom