Zjištění existence tabulky v databázi

Funkce:

Public Function TableExists(DatabaseName As String, 
TableName As String) As Boolean

   'DataBaseName: jméno a cesta k souboru 
   'tablename: jméno tabulky pro test
   'pokud DB neexistuje, vyvolá chybu

   Dim oDB As Database, td As TableDef

   On Error GoTo errorhandler
   Set oDB = Workspaces(0).OpenDatabase(DatabaseName)
   On Error Resume Next

   Set td = oDB.TableDefs(TableName)
   TableExists = Err.Number = 0
   oDB.Close

   Exit function

errorhandler:

   Err.Raise Err.Number
   Exit Function

End Function

Zpět

Autor: The Bozena