Results 1 to 3 of 3

Thread: Object is no longer valid

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Atlanta, GA
    Posts
    80

    Angry

    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
    Kevin

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Which line does it give the error at?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Atlanta, GA
    Posts
    80
    Nevermind... wasn't trimming the DB Field. Extra spaces were screwing it up somhow....

    Thanks!
    Kevin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width