Delete query question

N

Neil

Hello,

I have a delete query that I run when finding duplicate data. I make the SQL
string in my procedure and then execute it as follows:

CurrentDb.Execute strSQL, dbFailOnError

Is there any way of getting how many records I have deleted doing this?

TIA,

Neil.
 
F

fredg

Hello,

I have a delete query that I run when finding duplicate data. I make the SQL
string in my procedure and then execute it as follows:

CurrentDb.Execute strSQL, dbFailOnError

Is there any way of getting how many records I have deleted doing this?

TIA,

Neil.

I don't believe so.
Why not use
DoCmd.RunCommand strSQL
instead?
You will get a message with the number of records to be deleted and an
opportunity to cancel the deletions if you wish to.
 
T

TC

Don't use CurrentDb() "in line" like that. Save its return value in a
variable, & use the variable:

dim db as database
set db = currentdb()
' then use db instead of CurrentDb()

To get the # of records affected by an action query:

db.execute ...
msgbox db.recordsaffected

Remember to de-allocate db when finished:

set db = nothing

HTH,
TC
 
N

Neil

Thanks TC,

I though it was the RecordsAffected property that I had to use but it
returned 0 every time until i used the variable. Now it works ok.

Neil.
 

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

Similar Threads


Top