Results 1 to 4 of 4

Thread: Item not found in this collection [Solved]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Resolved Item not found in this collection [Solved]

    Hello I am kinda new at this stuff and I am trying to add a new record into a table within my access DB and the data is coming from a few variables I made. The following code is what I am using but when I am assigning the table to as a record set I get the error message in the subject. Here is my code:

    VB Code:
    1. Public Sub UpdateIncLog()
    2. Dim tCurrentTime As Date
    3. Dim dCurrentDate As Date
    4. Dim rsIncFileLog As Recordset
    5. Dim dbsCurrent As Database
    6.  
    7. Set dbsCurrent = CurrentDb
    8. Set rsIncFileLog = dbsCurrent.Recordsets("Incoming File Log")
    9.  
    10. tCurrentTime = Time("hh:mm:ss")
    11. dCurrentDate = Date
    12.  
    13. With rsIncFileLog
    14.     .AddNew
    15.     .Fields("Filename") = stFilename
    16.     .Fields("Date") = dCurrentDate
    17.     .Fields("Time") = tCurrentTime
    18.     .Update
    19. End With
    20. End Sub
    Last edited by Besoup; Feb 10th, 2005 at 12:55 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Item not found in this collection

    Thats because you havent opened a recordset yet. So when you try to access the
    rs "Incoming File Log" it gives you the error that it cant find it. Use the .OpenRecordset
    method first.

    Edit: Dont use reserved keywords for your fields. Change your fields to dDate and tTime or try using
    brackets around then when referencing them in code, like [Date] and [Time].
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Item not found in this collection [Solved]

    Got it, thanks again dude.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Item not found in this collection [Solved]

    No prob. Glad its working for you.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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