The best way is to restrict the user of adding an empty record.
But if you still want to delete an empty record, then you can do something like this. Add a reference to Microsoft ActiveX library 2.1 (or select the highest version you have installed), then use the code like this:
Assuming that:Code:Dim cn As New ADODB.Connection cn.Provider = "Microsoft.Jet.OLEDB.3.51" cn.Open "C:\MyDB.mdb", "admin", "" cn.Execute "Delete MyTable Where (Field1 Is Null And Field2 Is Null) Or (Field1 = "" And Field2 = "")
C:\MyDB.mdb is my database.
MyTable is a table in the database
Field1 and Field2 are two fields in the MyTable




Reply With Quote