Kamis, 16 April 2015

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: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar