'---------------------------------------------------------------------------------------
' Procedure : listTables
' Author : CARDA Consultants Inc.
' Website : http://www.cardaconsultants.com
' Purpose : Return a listing of all the tables in the database
' Copyright : The following code may be used as you please, but may not be resold, as
' long as the header (Author, Website & Copyright) remains with the code.
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' bShowSys - True/False whether or not to include system tables in the list
'
' Revision History:
' Rev Date(yyyy/mm/dd) Description
' **************************************************************************************
' 1 2008-June-01 Initial Release
'---------------------------------------------------------------------------------------
Function listTables(bShowSys As Boolean) As String
On Error GoTo listTables_Error
Dim db As DAO.Database
Dim td As DAO.TableDefs
Set db = CurrentDb()
Set td = db.TableDefs
For Each t In td 'loop through all the fields of the tables
If Left(t.Name, 4) = "MSys" And bShowSys = False Then GoTo Continue
Debug.Print t.Name
'CurrentDb().OpenRecordset ("DELETE * FROM " & t.Name)
Continue:
Next
Set td = Nothing
Set db = Nothing
If Err.Number = 0 Then Exit Function
listTables_Error:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf & "Error Number: " & _
Err.Number & vbCrLf & "Error Source: listTable" & vbCrLf & _
"Error Description: " & Err.Description, vbCritical, "An Error has Occured!"
Exit Function
End Function
Thursday, June 10th, 2010, 7:29 pm |
MS Access Tables, MS Access VBA Programming |
RSS feed
Pinging is disabled. But you can skip to the end and leave a
response.
November 8, 2011 at 8:41 am
excellent code.