|
-
Feb 10th, 2005, 11:48 AM
#1
Thread Starter
Frenzied Member
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:
Public Sub UpdateIncLog()
Dim tCurrentTime As Date
Dim dCurrentDate As Date
Dim rsIncFileLog As Recordset
Dim dbsCurrent As Database
Set dbsCurrent = CurrentDb
Set rsIncFileLog = dbsCurrent.Recordsets("Incoming File Log")
tCurrentTime = Time("hh:mm:ss")
dCurrentDate = Date
With rsIncFileLog
.AddNew
.Fields("Filename") = stFilename
.Fields("Date") = dCurrentDate
.Fields("Time") = tCurrentTime
.Update
End With
End Sub
Last edited by Besoup; Feb 10th, 2005 at 12:55 PM.
-
Feb 10th, 2005, 12:34 PM
#2
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 10th, 2005, 12:54 PM
#3
Thread Starter
Frenzied Member
Re: Item not found in this collection [Solved]
Got it, thanks again dude.
-
Feb 10th, 2005, 01:06 PM
#4
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|