Check for table existence

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.
 
P

Paul Overway

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top