Delete a record if certain text is not found

darag2358

Registered User.
Local time
Today, 20:35
Joined
May 4, 2001
Messages
28
I want to cleanup a table by searching record by record for the text "HGIO". The text may be inbedded within other text. If it is there, go to the next record, if not, delete the record. I'm new to VBA in the Access environment, so any help is appreciated. Running Access2002.

Thanks

This is what I have that doesn't work.....I'm not using the find function correctly
=============

Function Cleanup()

Dim rst As DAO.Recordset, c As Field

Set rst = CurrentDb.OpenRecordset("CICSPROD", dbOpenTable)

rst.MoveFirst
Do Until rst.EOF
With rst
If !Field1.Find("HGIO") Then .MoveNext
Else:
Recordset.Delete
End If
End With
Loop
Set rst = Nothing

End Function
 
Last edited:
Probably easier to create a delete query.

DELETE yourTable
WHERE (((YourField) Like "*HGIO*"));
 
Oh, duh...can you tell I'm new to Access?

Thanks!:o
 
Sorry it should be

DELETE * from yourTable
WHERE (((YourField) Like "*HGIO*"));
 

Users who are viewing this thread

Back
Top Bottom