how to check existence of table

  • Thread starter Thread starter Sunny
  • Start date Start date
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
 
if an access table

dim tdf as tabledef
set tdf=nothing
on error resume next
set tdf=dbnow.tabledefs("mywantedtable")
on error goto 0
if tdf is nothing then
'table not found
else
set tdf=nothing 'clear memory
end if
 
Back
Top