Why will this query not work?

MarkA70

Registered User.
Local time
Today, 05:22
Joined
Jan 30, 2016
Messages
43
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
 
You don't need any of this code.
Just run a delete query.
 

Users who are viewing this thread

Back
Top Bottom