I need help using a two column List Box in Access VBA

Hi Experts,
I am using the following code to add values to my 2 column listbox.  The problem is that, it only displays the first column and the values in the second column. I have my Row Source Type set to Value List and column count = 2.  I have included my code below.  What do I need to do to display both columns in my List Box?

Thanks in advance,
mrotor
Private Sub Form_Load()
    Dim adoRS As New ADODB.Recordset
    Dim adoCN As New ADODB.Connection
    Dim adoCmd As New ADODB.Command
    Dim strItems As String
    Dim strConn As String
    '******* Get the assocaite info from the db *******
    strConn = modConnTools.fL50_GetConnString("FAEAGLE")
    
    With adoCN
        .ConnectionString = strConn
        .Open
    End With
    
    With adoCmd
        .CommandText = "dbo.u_FASST_STTF_ListOfApps_ssp"
        .CommandType = adCmdStoredProc
        .ActiveConnection = adoCN
    End With

    'Set the cursor location to client
    With adoRS
        .CursorLocation = adUseClient
        .CursorType = adOpenStatic
        .LockType = adLockBatchOptimistic
        Set .Source = adoCmd
        .Open
    End With
    
    'Disconnect the recordset
    Set adoRS.ActiveConnection = Nothing
    If adoCN.State = adStateOpen Then adoCN.Close
    Me.lstAvailableValues = ""
    'Now load the new data
    strItems = ""
    If Not (adoRS.EOF And adoRS.BOF) Then
        Do Until adoRS.EOF
            strItems = strItems & adoRS(0) & ";" & adoRS(1) & ";"
            adoRS.MoveNext
        Loop
        
        Me.lstAvailableValues.RowSource = strItems
    End If
End Sub

Open in new window

mainrotorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rockiroadsCommented:
What are the column widths? Check that in form design
0
rockiroadsCommented:
an alt. way to add items to a list is to use additem

        Do Until adors.EOF
            Me.lstAvailableValues.AddItem adors(0) & ";" & arors(i)
            adors.MoveNext
        Loop

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AshokSr. Software EngineerCommented:
Dim strArray(1 To 3, 1 To 2) As Variant
strArray(1, 1) = "Value 1"
strArray(1, 2) = "Value 2"
strArray(2, 1) = "Value 3"
strArray(2, 2) = "Value 4"
strArray(3, 1) = "Value 5"
strArray(3, 2) = "Value 6"

With ListBox2
.ColumnCount = 2
.List = strArray
End With

HTH
0
aikimarkCommented:
I'm surprised you are getting anything, since you close the connection before you iterate the recordset.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.