Results 1 to 3 of 3
  1. #1
    LittleRock Z is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2024
    Posts
    5

    item not found in collection, error cdoe 3265

    Why does the code work for Grave D, but not for Grave E


    I choose not to use SQL, I wanted to learn this way

    Grave D spelling of field name as copied from same table in design mode with one space
    Grave E spelling of field name as copied from same table in design mode with 2 spaces

    Code:
    Sub Debuger()
    
    Dim Recset As Recordset
     Set Recset = CurrentDb.OpenRecordset("Sheet1")
    
    Dim Allnames As Recordset
    Set Allnames = CurrentDb.OpenRecordset("allnames")
        ' access to Table Allnames
    
    Dim Blanks As String
    Blanks = "   "
    Dim x As Integer
    x = 1
    
     Allnames.MoveFirst         ' P211
     '  Allnames.MoveNext
     '  Allnames.MoveNext
     '  MsgBox Allnames![aname] & "  owner is"
    Do Until Allnames.EOF       'P257  erase previous contents
     Allnames.Delete
     Allnames.MoveNext
    Loop
    'Allnames.Close
    'Recordset = Nothing
    
    MsgBox "CLEARED"
    
    
      MsgBox Recset![GRAVE D] & "  AT D"
      If Recset![GRAVE D] > Blanks And Recset![GRAVE D] <> "DNA" Then
        Allnames.AddNew   ' record
        Allnames![AName] = Recset![GRAVE D]   ' copy field to Allnames table
        Allnames![lot] = Recset![lot #]
        Allnames![location] = "Grave D"  ' name of field, not contents  Recset![contact]
        Allnames.Update
      End If
    
     MsgBox Recset![Grave  E]    ' Item not found in collection
      If Recset![Grave  E] > Blanks And Recset![Grave E] <> "DNA" Then
        Allnames.AddNew   ' record
        Allnames![AName] = Recset![Grave  E]   ' copy field to Allnames table
        Allnames![lot] = Recset![lot #]
        Allnames![location] = "Grave  E"  ' name of field, not contents  Recset![contact]
        Allnames.Update
      End If
    
    End Sub

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,419
    Code:
      If Recset![Grave  E] > Blanks And Recset![Grave E] <> "DNA" Then
    Not same number of spaces in field name. Very surprised this does not produce runtime error.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    normally you just run a query(s) rather than write code to cycle thru the recordset.

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

Similar Threads

  1. Replies: 11
    Last Post: 02-02-2019, 11:54 PM
  2. Replies: 6
    Last Post: 04-20-2018, 04:45 AM
  3. Error "item not found in this collection"
    By andy49 in forum Queries
    Replies: 7
    Last Post: 11-12-2016, 12:46 PM
  4. 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
  5. item not found in this collection
    By rockell333 in forum Queries
    Replies: 1
    Last Post: 09-24-2015, 03:20 PM

Tags for this Thread

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