Jumat, 08 September 2017

RE: [MS_AccessPros] delete all the records from all the tables

 

Hi Art

The short answer is "no".

However, it is easy to write a short VBA procedure that loops through the TableDefs collection and, for each candidate, execute a DELETE statement:

                db.Execute "DELETE FROM [" & tdf.Name & "];", dbFailOnError

Of course, you need to leave system tables alone, and you need to handle relational integrity issues – for example, you cannot delete from Customers because Orders has related records.  For a specific database, you can list the table names in an array in the correct order.  If you want your code to be general, you could use the TableDef loop and trap the "related records" error, setting a Retry flag and Resume Next.  Continue to reset the flag and repeat the loop until you finish and the flag is not set.

Best wishes,
Graham

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Saturday, 9 September 2017 07:13
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] delete all the records from all the tables

 

 

Is there a way to delete all the records from all the tables without doing a individual delete statement for each?

 

Thank you,

 

Art Lorenzini

SD

__._,_.___

Posted by: "Graham Mandeno" <graham@mandeno.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar