Check for table existence

  • Thread starter Thread starter Karthik
  • Start date Start date
K

Karthik

Hi,

I want to find out whether a table exists or not in Ms-Access. How do I do
the same?

In SQL Server I would have checked Sysobjects table to find the same. How do
I go about this in SQL Server?

Thank you in advance

Regards,
Karthik.
 
Test for the table, and if you get an error, you'll know it doesn't exist,
i.e.,

Function TableExists(TableName As String) As Boolean

Dim db as database
Dim tdf as tabledef

On error resume next

Set db =currentdb()

Set tdf = db.TableDefs(TableName)

TableExists = (Err.Number=0)

End Function
 
Back
Top