Kamis, 16 April 2015

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-

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:


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



__._,_.___

Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)

.

__,_._,___

Tidak ada komentar:

Posting Komentar