Mega Code Archive

 
Categories / VisualBasic Script / Access
 

Checking for Existence of Tables

Function TableExists(WhichTable)     Dim cnn As ADODB.Connection     Dim rst As ADODB.Recordset     Dim fld As ADODB.Field     TableExists = False     MyConn = "C:\t.mdb"     Set cnn = New ADODB.Connection     With cnn         .Provider = "Microsoft.Jet.OLEDB.4.0"         .Open MyConn     End With     Set rst = cnn.OpenSchema(adSchemaTables)     Do Until rst.EOF         If LCase(rst!Table_Name) = LCase(WhichTable) Then             TableExists = True             GoTo ExitMe         End If         rst.MoveNext     Loop ExitMe:     rst.Close     Set rst = Nothing     cnn.Close End Function