Record count

B

Bill

When the SQL DELETE query is used to
delete several records, if any, where does
SQL report how many records were
deleted. Or, do I have to run a SELECT
first to get a record count?

Thanks,
Bill
 
J

John Spencer

In a VBA function you can use the recordsAffected property.

Dim StrSQL as String

Dim db as DAO.DB
Set db = CurrentDb()

strSQL = "DELETE * FROM TableA WHERE X = 20"
db.execute strSQL, dbFailOnError
MsgBox db.recordsAffected & " Records deleted"

Hope that helps.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
B

Bill

Yes, that will do nicely.
Thanks,
Bill


John Spencer said:
In a VBA function you can use the recordsAffected property.

Dim StrSQL as String

Dim db as DAO.DB
Set db = CurrentDb()

strSQL = "DELETE * FROM TableA WHERE X = 20"
db.execute strSQL, dbFailOnError
MsgBox db.recordsAffected & " Records deleted"

Hope that helps.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 

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