Solved

copy file into listbox

Posted on 2002-03-22
3
133 Views
Last Modified: 2010-05-02
how can i copy the record (e.g. Street Name field) in the database into the listbox ?
0
Comment
Question by:tabing16
[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
 

Expert Comment

by:carloss
ID: 6890419
Here's a sample:

Dim rsList as ADODB.Recordset

Set rsList = new ADODB.Recordset

With rsList
.Open "SELECT CompanyName FROM Customers", "PROVIDER=SQLOLEDB;Integrated Security=SSPI;DATABASE=Northwind;SERVER=(local)", adOpenForwardOnly, adLockReadOnly, adCmdText

While Not(.EOF)
lstNames.AddItem .Fields(0).Value
.MoveNext
Wend
End With
0
 

Author Comment

by:tabing16
ID: 6890560
I'm sorry, let me correct my question...i had succeeded to load the database field (Street Name field) into the listbox, i  did the random function to the field using SQL statement, but the problem is it was sequential random, what i want is a random result that is different everytime I start the application, and one more problem is i could not put randomize keyword inside the SQL statement, is there anyway to do random function outside the SQL statement but affect the result ot Street Name and put the random result into the listbox ?
0
 

Accepted Solution

by:
carloss earned 30 total points
ID: 6892183
Add an order by clause and use the information_schema views to get a column name.  The view has an ordinal position column which is numeric.  Use this value when selecting a column.  Since its numeric, you can use the RAND() function to get a random numeric value, and select the column name based on a comparison of the random number and the column's ordinal position.
0

Featured Post

Industry Leaders: 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

628 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