You are on page 1of 2

Option Compare Database

Sub tab_del()

Public Function empty_tables() As Boolean

'======================================================

' Author: wongm003

' Use to empty all visible tables in current database.

'

' Note: if you do not want to prompt the user for each

' table comment out the second if statement (if msgbox...).

'======================================================

On Error GoTo hndl_err

Dim tbl As Variant

Dim strSQL As String

DoCmd.SetWarnings False

For Each tbl In CurrentDb.TableDefs

If Not Application.GetHiddenAttribute(acTable, tbl.Name) Then

If MsgBox("Empty " & tbl.Name & "?", vbYesNo) = vbYes Then

strSQL = _

"DELETE " & tbl.Name & ".* " & _

"FROM " & tbl.Name & ";"

DoCmd.RunSQL strSQL

End If

End If

Next tbl
empty_tables = True

normal_exit:

DoCmd.SetWarnings True

Exit Function

hndl_err:

empty_tables = False

Resume normal_exit

End Function

You might also like