Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2015
    Posts
    2

    Unanswered: Run-time Error 3265 - Item not found in collection

    Hi,

    I have an access database, which imports various excel files.
    I get the Run-time 3265 error.

    Below is the code.

    The error is in: rs(C).Value = DataRange(R, C)

    Anyone able to help?

    Thanks!



    Public Sub Load6(WorksheetName As String, RangeAddress As String, AccessTableName As String)

    '================================================= ================================================== ================
    Set prWorksheet = prWorkbook.worksheets(WorksheetName)
    DataRange = prWorksheet.Range(RangeAddress)

    RowCount = prWorksheet.Range(RangeAddress).rows.Count
    ColCount = prWorksheet.Range(RangeAddress).Columns.Count


    Set db = CurrentDb

    '================================================= ================================================== =====================================

    Set rs = db.OpenRecordset(AccessTableName, dbOpenDynaset)

    If rs.RecordCount > 0 Then
    rs.MoveFirst
    End If


    For R = 1 To RowCount

    rs.FindFirst "[SOWNumber] =" & prSOWNumber & "AND [FeeNumber] = " & prFeeNumber & "AND [VERSION] = " & prVersion & " AND [SCOPEYEAR] =" & 2016 & "AND [PROJECTID] = " & R



    If rs.NoMatch = False Then



    rs.Edit

    rs![Version] = prVersion
    rs![FeeNumber] = prFeeNumber
    rs![SOWNumber] = prSOWNumber
    rs![SCOPEYEAR] = 2016
    rs![PROJECTID] = R
    rs![TitleID] = (C - 3)

    For C = 4 To ColCount

    rs(C).Value = DataRange(R, C)
    Next

    rs![DateStamp] = Now()

    rs.Update






    ElseIf rs.NoMatch = True Then

    If Len(Trim(DataRange(R, 1))) > 0 And Len(Trim(DataRange(R, 2))) > 0 Then


    rs.AddNew

    rs![Version] = prVersion
    rs![FeeNumber] = prFeeNumber
    rs![SOWNumber] = prSOWNumber
    rs![SCOPEYEAR] = 2016
    rs![PROJECTID] = R
    rs![TitleID] = (C - 3)

    For C = 4 To ColCount

    rs(C).Value = DataRange(R, C)

    Next

    rs![DateStamp] = Now()

    rs.Update

    End If



    End If


    Next


    rs.Close




    '================================================= ================================================== ===================

    End Sub

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    just guessing the specified cells in datarange(R,c) are invalid.
    so either you need to beef up your range /error checking, install error handling
    validate that R & C contain data
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Nov 2015
    Posts
    2
    Have checked, and there is data on those cells.

    any other solutions?

    Thanks!


    Quote Originally Posted by healdem View Post
    just guessing the specified cells in datarange(R,c) are invalid.
    so either you need to beef up your range /error checking, install error handling
    validate that R & C contain data

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what is rs(c) meant to represent?

    Run Time Error 3265 - is 'Item not found in this collection'
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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