G
Guest
I need a method of populating a List Box using code. I am trying to create a
form where you can see who is logged into the application. I found some code
in Oreilly ACC Cookbook but it uses a method or member not found (.AddItem).
The code below is attached to a forms on_Open() property and contains a list
box named lboConnections with two columns named Compter Name, and User Name.
my referances are(VB for App, MS 9.0 OL, OLE Auto, and MS ActiveX Data Obj
2.1 Lib)
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strComputerName As String
Set cnn = CurrentProject.Connection
Set rst = cnn.OpenSchema(adSchemaProviderSpecific, , _
"{947bb102-5d43-11d1-bdbf-00c04fb92675}")
lboConnections.RowSource = vbNullString
lboConnections.AddItem "Computer Name;Login Name"
Do While Not rst.EOF
If rst("Connected") Then
strComputerName = rst("Computer_Name")
lboConnections.AddItem _
Left(strComputerName, _
InStr(strComputerName, vbNullChar) - 1) & _
";" & rst("Login_Name")
End If
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set cnn = Nothing
I can sucessfully retreive the users via code, but I can't figure out how to
feed that to a form.
form where you can see who is logged into the application. I found some code
in Oreilly ACC Cookbook but it uses a method or member not found (.AddItem).
The code below is attached to a forms on_Open() property and contains a list
box named lboConnections with two columns named Compter Name, and User Name.
my referances are(VB for App, MS 9.0 OL, OLE Auto, and MS ActiveX Data Obj
2.1 Lib)
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strComputerName As String
Set cnn = CurrentProject.Connection
Set rst = cnn.OpenSchema(adSchemaProviderSpecific, , _
"{947bb102-5d43-11d1-bdbf-00c04fb92675}")
lboConnections.RowSource = vbNullString
lboConnections.AddItem "Computer Name;Login Name"
Do While Not rst.EOF
If rst("Connected") Then
strComputerName = rst("Computer_Name")
lboConnections.AddItem _
Left(strComputerName, _
InStr(strComputerName, vbNullChar) - 1) & _
";" & rst("Login_Name")
End If
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set cnn = Nothing
I can sucessfully retreive the users via code, but I can't figure out how to
feed that to a form.