OK its working but I notice I am catching
Deleting from table MSysComplexColumns
which I need to leave out.
With Warm Regards,
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265 Ext. 130
Fax (605)964-1070
"Anyone who claimed that old age had brought them patience was either lying or senile."
From: "Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: Access Professionals Yahoo Group <ms_access_professionals@yahoogroups.com>
Sent: Thursday, April 16, 2015 2:17 PM
Subject: RE: [MS_AccessPros] Delete records from multiple tables
Oops. I see I assumed the table names "contain" SC not begin with SC. I would however add my Debug.Print and method of test running first to John's code.
Duane Hookom, MVP
MS Access
To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Thu, 16 Apr 2015 21:13:04 +0200
Subject: Re: [MS_AccessPros] Delete records from multiple tables
Art-
Is there a way to purge records in multiple tables via VBA. I have 12 tables that contains the letter SC in their name. I would like to be able to delete all the records in these tables but not effect other tables. Is it doable?
Thank you,
Art Lorenzini
Sioux falls, SD
Duane Hookom, MVP
MS Access
To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Thu, 16 Apr 2015 21:13:04 +0200
Subject: Re: [MS_AccessPros] Delete records from multiple tables
Art-
Easy.
Dim db As DAO.Database, tdf As DAO.Tabledef
Set db = CurrentDb
For Each tdf In db.Tabledefs
If Instr(tdf.Name, "SC") <> 0 Then
db.Execute "DELETE * FROM [" & tdf.Name & "]", dbFailOnError
End If
Next tdf
Set db = Nothing
Set tdf = Nothing
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
(Paris, France)
On Apr 16, 2015, at 9:03 PM, dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Thank you,
Art Lorenzini
Sioux falls, SD
__._,_.___
Posted by: Art Lorenzini <dbalorenzini@yahoo.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (6) |
.
__,_._,___
Tidak ada komentar:
Posting Komentar