Solved

showing multiple colums in list box

Posted on 2014-01-03
3
171 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

762 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

12 Experts available now in Live!

Get 1:1 Help Now