VBA code for table deletion

S

Smigidy

I have the following code to delete all table data except for what is in the
Switchboard Items table, but there's a compile error. Any suggestions?

Public Sub sDeleteAllTableData()
Dim dbAny As DAO.Database
Dim I As Long

Set dbAny = CurrentDb()
For I = 0 To dbAny.TableDefs.Count - 1
If (dbAny.TableDefs(I).Attributes And dbSystemObject) = 0 or
If (dbany.tabledefs(i).name="Switchboard Items") Then
dbAny.Execute "DELETE FROM [" & dbAny.TableDefs(I).Name & "]"
End If
Next I

End Sub

Thanks, Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top