Check that a table exists

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to check using SQL in VB that a Table exists, when you know
what the table name is?

I need some sample syntax: The following Syntax will give you an idead of
what I am looking for...... this is incorrect by the way......

if TBL_CUSTOMERS.Exists then
code
endif
 
No need for SQL: you can use the following function:

Function TableExists(TableName) As Boolean

If IsNull(DLookup("[Name]", "MsysObjects", _
"[Type] In (1,4,6) " & _
"And [Name] ='" & TableName & "'")) Then
TableExists = False
Else
TableExists = True
End If

End Function

Use it like:

If TableExists("TBL_CUSTOMERS") Then
code
End If
 
Back
Top