How to delete some records in all the tables in a database?

  • Thread starter Thread starter Athena
  • Start date Start date
A

Athena

Hello,

I am new to this so sorry for the this simple question.

I want to delete certain records on all the tables in a database using
ADO from VB6. I can have a line like below:

sSQL="DELETE * FROM TableName WHERE FieldID='" & FieldName & "'"

But how can I scan all the tables in the database so that TableName above
is each one of the tables in the database.

Thank you.

Athena
 
Dim tbl as TableDef

For Each tbl in CurrentDb.TableDefs
sSQL="DELETE * FROM " & tbl.Name & " WHERE FieldID='" & FieldName &
"'"
 
Thank you Vlado. I did not expect it to be this simple! I will try soon.
Thanks again.

Athena
 

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

Back
Top