Solved

Put this in a listbox .

Posted on 2004-09-29
2
303 Views
Last Modified: 2013-12-25
   If Not RsType.EOF Then
            With ctrControl
                Do Until RsType.EOF
                    .AddItem Trim(RsType("Book"))
                    .AddItem Trim(RsType("cost"))
                    .AddItem Trim(RsType("list"))
                   .ItemData(.NewIndex) = RsType("id")
                    RsType.MoveNext
                Loop
            End With
        End If
I have this achieve but it is displaying in the listbox incorrectly.

The question is how to put the resultset in each column in a listbox
0
Comment
Question by:zachvaldez
  • 2
2 Comments
 
LVL 8

Accepted Solution

by:
mladenovicz earned 125 total points
ID: 12180896
you should use listview control, not listbox
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12181013
or you can set fixed length font (e.g Courier New) for list box, and try sthg like this
const MaxLen =15

   If Not RsType.EOF Then
            With ctrControl
                Do Until RsType.EOF
                    .AddItem m_FormatItem(RsType("Book"), maxLen) & "|"  & m_FormatItem(RsType("cost"), maxLen) & "|" & m_FormatItem(RsType("list"), maxLen)

                   .ItemData(.NewIndex) = RsType("id")
                    RsType.MoveNext
                Loop
            End With
        End If

Private Function m_FormatItem(Itm As String, ItemLen As Integer) As String
    m_FormatItem = Trim(Itm) & Space(ItemLen - Len(Itm))
End Function

where maxlen is "column" width - you have to be sure that string from rs is not larger than maxlen
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now