?
Solved

Conditional Formatting in a ListBox (Access :: VBA)

Posted on 2007-10-11
12
Medium Priority
?
3,834 Views
Last Modified: 2013-11-28
Hello Experts,
I am building a search form that will search for inactive/active records.  What I am trying to do is have the inactive records appear in grey and the active records to appear blue.  For each record, there is an attribute called blnActive that returns true/false values.
 
I am capable of determining the SQL, however, I need assistence with the VBA syntax.  Here is my pseudo code:

For i = 1 To rec Step 1
                item = rsP.Fields(0) & ";" & rsP.Fields(1)
                If rsP.Fields(2) = False Then
                    ' this line item should be 8421504
                Else
                    ' this line item should be 0
                End If
                Me.lstGrant.AddItem (item)
                rsP.MoveNext
            Next i

Thank you for your quick response!

Wendee
0
Comment
Question by:wendeenelson
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 1000 total points
ID: 20058440
Individual lines in a standard ListBox cannot be formatted in any manner.  ALL lines will be of the same FONT, SIZE, BOLD/UNBOLD, COLOR...

Your only hope MIGHT be to use a Third Party listView control, but I cannot suggest any to look into, becuase Access only uses ActiveX (COM) controls, and with the introduction of .NET, no vendors are still selling COM/ActiveX controls for any purpose.

AW
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 20058468
you can not do this in a listbox. you can use a subform
see if this link helps
http://www.lebans.com/alternatecolordetailsection.htm
0
 

Author Comment

by:wendeenelson
ID: 20058478
Thank you for your comment.  

I have had help with this problem before.  However, someone on EE deleted my question that was reserved in my Knowledge Base.  :- |  

In addition to VBA, I work with Component Toolbox (which is ActiveX).  Part of me doubts that is what I used before to solve this problem, but I will double check.

Thank you, once again!
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20058503
0
 

Author Comment

by:wendeenelson
ID: 20058631
Is there a resource where I can retrieve the properties of ctList?  (i.e. the equivalent of "rowsource" and "additem" syntax terms.)

Thank you.
0
 
LVL 75
ID: 20058644
dbi-tech rocks :-)

mx
0
 

Author Comment

by:wendeenelson
ID: 20059011
This is what I came up with for my code:
        If rs.RecordCount > 0 Then
            rs.MoveLast
            rsCt = rs.RecordCount
            rs.MoveFirst
           
            For i = 0 To rsCt - 1 Step 1
                intFunderID = rs.Fields(0)
                txtName = rs.Fields(1)
                blnActive = rs.Fields(2)
                item = intFunderID & ";" & txtName & ";" & blnActive
                Me.ctList.AddItem (item)
                rs.MoveNext
            Next i
        End If

Where do I put the formatting code?  What is the syntax?

Thank you for your continued help.
0
 

Author Comment

by:wendeenelson
ID: 20065698
I have decided not to use DBI-Tech's controllers afterall.  

I will accept the fact that I cannot change colors of the text.  Instead, I created a conditional statement:

IF blnActive = False then
   txtActive = "Inactive"
else
   txtActive = "Active"
end if

Then I am just displaying that in a column next to the Funder names.  Where I stand right now, this discussion is complete.
0
 
LVL 75
ID: 20066834
"I have decided not to use DBI-Tech's controllers afterall.  "

Just curious as to why not?

mx
0
 

Author Comment

by:wendeenelson
ID: 20066955
As far as I can tell, there is very little documentation for syntax out there.  I spent $400 on this software and the company wants to charge me more $$$ to get help developing with their product.  

Do you another resource for DBI-Tech Development Documentation?
0
 
LVL 75
ID: 20067023
Last I knew, all DBI controls come with a complete help file and sample mdb, certainly better documentation and example that M# has every produced.

mx
0
 

Author Comment

by:wendeenelson
ID: 20067167
They do, but it doesnot go far enough with explaining how the ListCargo works.- I am new to that arena
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question