Results 1 to 7 of 7
  1. #1
    tummasm is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2018
    Posts
    4

    Run-time error '3265' - Item not found in this collection.

    Hey,

    I am pretty new to programming in Access and I am trying to update fields in a table in a simple manner. This is my code:

    Function FillProdCode()
    1
    2 Dim rstFoundItems As Recordset
    3 Dim rs As DAO.Recordset
    4 Dim cursku As String
    5
    6 Set rs = CurrentDb.OpenRecordset("FoundItems")
    7
    8 If Not (rs.EOF And rs.BOF) Then
    9 rs.MoveFirst
    10 Do Until rs.EOF = True
    11
    12 If rs!Level = 0 Then


    13
    14 cursku = rs!Item_Number
    15
    16 End If
    17
    18 With rs
    19 .Edit
    20 .Fields("Prod_Code").Value = cursku
    21 .Update
    22 End With
    23
    24 rs.MoveNext
    25 Loop
    26 Else
    27 MsgBox "There are no records in the recordset."
    28 End If
    29
    30 MsgBox "Finished looping through records."
    31
    32 rs.Close
    33 Set rs = Nothing
    34
    End Function

    I get "Run-time error '3265': Item not found in this collection." on the line 20.

    Does anyone know what I'm doing wrong?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    I think it's telling you that there is no field called "Prod_Code" in that recordset
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    tummasm is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2018
    Posts
    4
    Quote Originally Posted by Bob Fitz View Post
    I think it's telling you that there is no field called "Prod_Code" in that recordset
    Click image for larger version. 

Name:	founditems table.JPG 
Views:	11 
Size:	37.1 KB 
ID:	33650

    There is a column called "Prod_Code" which has the fields that I want to update. What am I not getting?

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Perhaps:
    20 .Fields("Prod_Code") = "cursku"
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    tummasm is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2018
    Posts
    4
    Quote Originally Posted by Bob Fitz View Post
    Perhaps:
    20 .Fields("Prod_Code") = "cursku"
    Still the same error

  6. #6
    tummasm is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2018
    Posts
    4
    Quote Originally Posted by Bob Fitz View Post
    I think it's telling you that there is no field called "Prod_Code" in that recordset
    This was the error! The field was called "Prod_ Code" instead of "Prod_Code"... Frustrating, haha.

  7. #7
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    This is why underscores can be a bad idea - it's hard to spot them sometimes. Use Camel case and no spaces is much easier to troubleshoot.
    ProdCode
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Item not found in this collection
    By Niko in forum Forms
    Replies: 12
    Last Post: 10-13-2017, 03:13 PM
  2. Error "item not found in this collection"
    By andy49 in forum Queries
    Replies: 7
    Last Post: 11-12-2016, 12:46 PM
  3. Run-Time Error '3265': Item Not Found In This Collection
    By Voodeux2014 in forum Programming
    Replies: 3
    Last Post: 01-29-2016, 09:04 AM
  4. Item Not Found In This Collection (ListBox)
    By Voodeux2014 in forum Forms
    Replies: 8
    Last Post: 10-19-2015, 11:09 AM
  5. item not found in this collection
    By rockell333 in forum Queries
    Replies: 1
    Last Post: 09-24-2015, 03:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums