Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate List Box 1

Status
Not open for further replies.

sucoyant

IS-IT--Management
Sep 21, 2002
213
US
Good day!

I have a form named ShowDatabaseUsers that contains the following.

List Box:
lstCompName
lstEmpName

Button
cmdClose

In the "On Open" event of the form I have code that populates lstCompName with the names of users computers that are currently using the database. The code looks like this:

Code:
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset

    
cn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=G:\xxx\QualityControl.mdb;Jet OLEDB:Database Password=somePassword"

cn.Properties("Jet OLEDB:Connection Control") = 1
    
Set rs = cn.OpenSchema(adSchemaProviderSpecific, , _
"{947bb102-5d43-11d1-bdbf-00c04fb92675}")
    
'Output the list of all users in the current database.
Do While Not rs.EOF
    lstCompName.AddItem rs.Fields(0)
    rs.MoveNext
Loop
     
cn.Close

I also have a table with employee names and computer numbers. The table looks like this

Table (Employees):
Employee
compID


My question is this. How would I go about populating lstEmpName with the Employee name pulled from the Employees table?

________________________________________
BUDDHA.gif
Buddha. Dharma. Sangha.
 
The easiest way is to create a query

SELECT Employee FROM EMPLOYEES;


Then, in the recordsource property of the lstEmpName, select the query that you created.

There are also many other ways to do this, let me know if this doesn't suit your needs.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top