Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 22nd, 2008, 11:32 PM
Authorized User
 
Join Date: May 2007
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default Conditional Formatting a Listbox - refining it

I have found a method of doing conditional formating a listbox to the individual field using subitem code as follows (not the complete code however you'll get the entire idea as its copied from a website tutorial)

I've played with it enough times to see that it works thoroughly, even though most say its not possible to do it.

With Me.ListView1
For Counter = 1 To Me.ListView1.ListItems.Count
        Set Item = Me.ListView1.ListItems.Item(Counter)
        ' Set the variable to the amount
        Amount = Item.SubItems(4)
If Amount <= 500 Or Amount <= 1000 Then
.ListItems.Item(Counter).ForeColor = vbRed
.ListItems.Item(Counter).ListSubItems(1).ForeColor = vbRed
.ListItems.Item(Counter).ListSubItems(2).ForeColor = vbRed
.ListItems.Item(Counter).ListSubItems(3).ForeColor = vbRed
.ListItems.Item(Counter).ListSubItems(4).ForeColor = vbRed
else
'duplicated just make it vbBlack
.ListItems.Item(Counter).ForeColor = vbBlack
.ListItems.Item(Counter).ListSubItems(1).ForeColor = vbBlack
.ListItems.Item(Counter).ListSubItems(2).ForeColor = vbBlack
.ListItems.Item(Counter).ListSubItems(3).ForeColor = vbBlack
.ListItems.Item(Counter).ListSubItems(4).ForeColor = vbBlack
end if

Next Counter
Me.ListView1.Refresh

The only thing i would prefer is to make the background instead the colour rather than the text as even making them individually bold isn't really effective enough. A coloured box or the equivalent, such as highlight, would be far better.

My question is can anyone point me in the direction of the syntax and options that all work with this code as the website isn't responding to questions on it.

The code is dependent on an unusual reference being loaded - Microsoft Common Controls 6.0(SP6) - MSCOMCTL.OCX

 
Old June 23rd, 2008, 07:40 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Use the same method but use .BackColor for the background or highlight.



mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old June 23rd, 2008, 07:42 AM
Authorized User
 
Join Date: May 2007
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried that and it gets kicked out on compiling.

 
Old June 23rd, 2008, 07:58 AM
Authorized User
 
Join Date: May 2007
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what i tried was:

.ListItems.Item(Counter).ListSubItems(4).BackColor = vbRed
.ListItems.Item(Counter).ListSubItems(4).ForeColor = vbWhite

that was the idea however it says property not recognised.






Similar Threads
Thread Thread Starter Forum Replies Last Post
conditional formatting jeremy1048 Access 4 July 3rd, 2008 11:20 AM
Conditional formatting vemaju Excel VBA 2 June 6th, 2007 04:41 AM
Conditional Formatting on Subform echovue Access 4 March 3rd, 2006 03:25 AM
Conditional Formatting Corey Access 1 November 8th, 2005 12:18 AM
Conditional Formatting... In Access??? lguzman Access VBA 2 September 23rd, 2004 03:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.