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
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].
Re: Item not found in this collection [Solved]
Got it, thanks again dude.
Re: Item not found in this collection [Solved]
No prob. Glad its working for you. :thumb: