I am trying to remove data from a table that is not needed. The code is shown below. When the Sub is called I get the error that
'Item Not Found in this Collection' I have checked and rechecked the query and the item is in the base query
Public Sub CleanUpAuctionItems()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim Items As DAO.Recordset
Set db = CurrentDb
Set qdf = db.QueryDefs("qry_AuctionItem_1")
Set Items = qdf.OpenRecordset(4)
MsgBox Items.RecordCount
With Items
.MoveFirst
Do While Not .EOF
If !Auction_Item_# = "" Then
.Delete
.Update
End If
.MoveNext
Loop
End With
Items.Close
Set Items = Nothing
db.Close
Set db = Nothing
qdf.Close
Set qdf = Nothing
Set prm = Nothing
End Sub
The code in red is what is causing the error.
What am I doing wrong? Thanks
'Item Not Found in this Collection' I have checked and rechecked the query and the item is in the base query
Public Sub CleanUpAuctionItems()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim Items As DAO.Recordset
Set db = CurrentDb
Set qdf = db.QueryDefs("qry_AuctionItem_1")
Set Items = qdf.OpenRecordset(4)
MsgBox Items.RecordCount
With Items
.MoveFirst
Do While Not .EOF
If !Auction_Item_# = "" Then
.Delete
.Update
End If
.MoveNext
Loop
End With
Items.Close
Set Items = Nothing
db.Close
Set db = Nothing
qdf.Close
Set qdf = Nothing
Set prm = Nothing
End Sub
The code in red is what is causing the error.
What am I doing wrong? Thanks