Solved

showing multiple colums in list box

Posted on 2014-01-03
3
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 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