Check if table exists (1 Viewer)

D-Fresh

Registered User.
Local time
Today, 23:45
Joined
Jun 6, 2000
Messages
225
I'm sure there's some way to do this through the system, but does anyone know how to check if a table exists in a database. I want to run a make table query if the table doesn't exist, and an append query if it does... What's the easiest way to go about checking the existence of the table?
 

D-Fresh

Registered User.
Local time
Today, 23:45
Joined
Jun 6, 2000
Messages
225
Alright well I just got it... Thanks anyway to everyone... In case other people would like it, here is the code.. I'm sure it could be quite useful..

Public Function CheckTable(TableName As String)

Dim db As Database
Dim tb As TableDef
Dim bExists As Boolean

Set db = CurrentDb
CheckTable = False

For Each tb In db.TableDefs

If TableName = tb.Name Then
CheckTable = True
Exit For
End If

Next tb

End Function
 

Users who are viewing this thread

Top Bottom