How to remove an empty record from a table

G

Guest

I'm new to VBA. I have a table with a couple of blank records in it amongst
other full records. I would like to know what code I can use to delete these
records. I tried ...

DoCmd.RunSQL "DELETE * FROM tblNewPImodems WHERE TRACK_NO = """";"

but it doesn't work. Any help would be appreciated.
 
T

Tim Ferguson

DoCmd.RunSQL "DELETE * FROM tblNewPImodems WHERE TRACK_NO = """";"

Assuming you want to find Null values of TRACK_NO then, this will work:

jetSQL = "DELETE FROM tblNewPImodems " & _
"WHERE TRACK_NO IS NULL;"

CurrentDB().Execute jetSQL, dbFailOnError


Note that using the DAO method also avoids the annoying "Are You Sure"
message box for the user.

Hope that helps


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top