How to delete all records from multiple tables with VBA loop? Access 2010

后端 未结 1 1127
生来不讨喜
生来不讨喜 2021-02-11 04:48

I want a VBA loop function that will delete all records from any table with a name like \"d2s_*\".

I\'ve found code to delete all records:

DoCmd.SetWarni         


        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-11 04:51

    Try:

    Dim T As TableDef
    DoCmd.SetWarnings False
    For Each T In CurrentDb.TableDefs
        If T.Name Like "d2s_*" Then
            DoCmd.RunSQL "DELETE * FROM " & T.Name
        End If
    Next T
    DoCmd.SetWarnings True
    

    0 讨论(0)
提交回复
热议问题