Checking if a Table Exists

  • Thread starter Thread starter Chaplain Doug
  • Start date Start date
Chaplain said:
How do I check programmatically to see if a table exists?
Thanks.

air code:

function isTable(cName as string) as boolean
dim td as tabledef
on error resume next
set td=currentdb.tabledefs(cname)
isTable=(err=0)
set td=nothing
end function
 
From a post dated 2/12/2004 by Access MVP Ken Snell:

This function will return a true value if the table exists in the database;
false if not.

Public Function TableIsHere(strTableName As String) As Boolean
Dim tdf As TableDef
TableIsHere = False
For Each tdf in CurrentDb.TableDefs
If tdf.Name = strTableName Then TableIsHere = True
Next tdf
End Function
 
Back
Top