Check Table Exist.

R

Rob

Hi Phoebe,

Make a function:

Function TableExists(strTableName As String) As Integer
Dim db As Database
Dim i As Integer
Set db = DBEngine.Workspaces(0).Databases(0)
TableExist = False
db.TableDefs.Refresh
For i = 0 To db.TableDefs.Count - 1
If strTableName = db.TableDefs(i).Name Then
'Table Exists
TableExist = True
Exit For
End If
Next i
Set db = Nothing
End Function

And call this function to check if the table exists
if TableExists("mytable") then
.....

Regards,

Rob
 

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