Solved

showing multiple colums in list box

Posted on 2014-01-03
3
192 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Multiple Open Excel Spreadsheets 12 39
Basic Excel DataEntry for Dashboard analysis 3 24
excel 2016 program to loop through scripts 6 33
VBA Help 18 43
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

786 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