-
Any help is appreciated... What am I doing wrong? The following code returns Error 3420 'Object is no longer valid.'
**********************************************************
In Form Load
**********************************************************
Dim objUser As New LBCom2.User
Dim cUsers As New Collection
Dim i As Integer
Set objUser = CreateObject("LBCOM2.User")
Set cUsers = objUser.GetAllActiveUsers()
For i = 1 To cUsers.Count
lstUser.AddItem cUsers.Item(i)
Next i
**********************************************************
LBCOM2.User Class
**********************************************************
Public Function GetAllActiveUsers() As Collection
'Get All Active Users from Database
strSQL = "SELECT UserID FROM Users WHERE Active = 1"
Dim objConn As ADODB.Connection
Dim objRS As ADODB.Recordset
Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
'Get Connection String
strConn = GetConnStr
'Make Connection
With objConn
.ConnectionString = strConn
.Open
End With
objRS.Open strSQL, objConn, adOpenForwardOnly, dLockReadOnly
Dim objColl As New Collection
Do While Not objRS.EOF
objColl.Add objRS.Fields("UserID")
objRS.MoveNext
Loop
Set GetAllActiveUsers = objColl
objRS.Close
objConn.Close
Set objColl = Nothing
Set objRS = Nothing
Set objConn = Nothing
End Function
Thanks,
Kevin
-
Which line does it give the error at?
-
Nevermind... wasn't trimming the DB Field. Extra spaces were screwing it up somhow....
Thanks!