I have been trying to solve a problem in a db I split. In my efforts I found in the Knowledge Base article 210266, "How to use the Seek Method on Linked Tables". In trying to get it to work, I generate runtime error #3265, Item not found in this collection
Could someone please look at this code and show me where I'm making my mistake?
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Dim dbs As Database
Dim t As TableDef
Dim rst As DAO.Recordset
Dim dbspath, SourceTable
Set dbs = DBEngine.Workspaces(0)(0)
dbspath = Mid(dbs(tblFuelType).Connect, InStr(1, tblFuelType.Connect, "=") = 1)
SourceTable = dbs(tblFuelType).SourceTableName
Set dbs = DBEngine(0).OpenDatabase("W:\Vehicle & Fuel Log\VFL001_be.mdb")
Set rst = dbs.OpenRecordset(tblFuelType, DB_OPEN_TABLE)
rst.Index = "PrimaryKey"
rst.Seek "=", Me!Fuel
rst.Edit
rst("FuelQty") = rst("FuelQty") - Me!QtyPumped
rst.Update
rst.Close
Set rst = Nothing
Set dbs = Nothing
End If
End Sub
The line that seems to be failing is in red
I really appreciate the assistance!
Could someone please look at this code and show me where I'm making my mistake?
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Dim dbs As Database
Dim t As TableDef
Dim rst As DAO.Recordset
Dim dbspath, SourceTable
Set dbs = DBEngine.Workspaces(0)(0)
dbspath = Mid(dbs(tblFuelType).Connect, InStr(1, tblFuelType.Connect, "=") = 1)
SourceTable = dbs(tblFuelType).SourceTableName
Set dbs = DBEngine(0).OpenDatabase("W:\Vehicle & Fuel Log\VFL001_be.mdb")
Set rst = dbs.OpenRecordset(tblFuelType, DB_OPEN_TABLE)
rst.Index = "PrimaryKey"
rst.Seek "=", Me!Fuel
rst.Edit
rst("FuelQty") = rst("FuelQty") - Me!QtyPumped
rst.Update
rst.Close
Set rst = Nothing
Set dbs = Nothing
End If
End Sub
The line that seems to be failing is in red
I really appreciate the assistance!