Solved

showing multiple colums in list box

Posted on 2014-01-03
3
207 Views
Last Modified: 2014-01-11
Folks

How do I display multiple columns in a listbox, my below code works but would be well suited with another column to display


strSQL = "SELECT * FROM TABLEA WHERE S_TYPE  ='OUTDOOR'"
   
    MsgBox (strSQL)
   
    Set oRsOracle = oConOracle.Execute(strSQL)
 
  Do Until oRsOracle.EOF
    ListBox1.AddItem oRsOracle.Fields(3).Value
        oRsOracle.MoveNext
  Loop
 
  oRsOracle.Close


all help will do
0
Comment
Question by:rutgermons
  • 2
3 Comments
 
LVL 15

Expert Comment

by:ChloesDad
ID: 39755075
You can build a string that is something like

ListBoxText = oRsOracle.Fields(3).Value & " - " & oRsOracle.Fields(4).Value

Then add that to the list box

ListBox1.AddItem ListBoxText

You can then have a play with adding CHR(9) (tab) to try and tabulate the text
0
 

Author Comment

by:rutgermons
ID: 39755259
the concept seems ok but I am using a loop like so

 Do Until oRsOracle.EOF
    ListBox1.AddItem oRsOracle.Fields(4).Value
     oRsOracle.MoveNext
  Loop

seems when I use your suggestion it only shows the values from the first record in the list but repeated continuously

i.e.

car-ford
car-ford
car-ford
car-ford

any ideas?
0
 
LVL 15

Accepted Solution

by:
ChloesDad earned 500 total points
ID: 39755283
Where did you put the code that I posted, it should replace this line in your code

   ListBox1.AddItem oRsOracle.Fields(4).Value

so you get

 Do Until oRsOracle.EOF
    ListBoxText = oRsOracle.Fields(3).Value & " - " & oRsOracle.Fields(4).Value
    ListBox1.AddItem ListBoxText

    oRsOracle.MoveNext
  Loop
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SIMPLE EXCEL IF STATEMENT THAT JUST WILL NOT WORK 12 42
Lookup - Vlookup 9 43
why cannot i download this excel file? 7 26
How to always round a decimal up 5 19
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

713 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