Table existence

Using VBA for Access, is there some way to test to see if a table exists?
If it does then continue processing, if not display a message "table not found, continuing processing on next table" and so forth.  
It's probably very simple but I'm doing this with lame books, lame F1 keys and no real support at my workplace.
Thanks for any help.
countyworkerAsked:
Who is Participating?
 
SSSoftwareConnect With a Mentor Commented:
To CountyWorker:

This works:

Public Sub Tabletest()

' Prints out all table names
' Tables that begin with MSys are Access internam tables
Dim I As Integer
For I = 0 To Application.CurrentDb.TableDefs.Count - 1
    Debug.Print Application.CurrentDb.TableDefs(I).Name
Next I

' Tests for the table "TestResults"
On Error GoTo NotFound
If Application.CurrentDb.TableDefs("TestResults").Fields.Count > 0 Then
    MsgBox "Table Found"
End If
On Error GoTo 0     ' reset the error handler
Exit Sub

NotFound:
    MsgBox "Table Not found"
End Sub

Good Luck,
Ed
0
 
SSSoftwareCommented:
To CountyWorker:

This works:

Public Sub Tabletest()

' Prints out all table names
' Tables that begin with MSys are Access internam tables
Dim I As Integer
For I = 0 To Application.CurrentDb.TableDefs.Count - 1
    Debug.Print Application.CurrentDb.TableDefs(I).Name
Next I

' Tests for the table "TestResults"
On Error GoTo NotFound
If Application.CurrentDb.TableDefs("TestResults").Fields.Count > 0 Then
    MsgBox "Table Found"
End If
On Error GoTo 0     ' reset the error handler
Exit Sub

NotFound:
    MsgBox "Table Not found"
End Sub

Good Luck,
Ed
0
 
CleanupPingCommented:
Hi countyworker,
This old question (QID 20566994) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
GPrentice00Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Accept SSSoftware's comment as Answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0
All Courses

From novice to tech pro — start learning today.