Aktif Veritabanı için
Dim GTabloAdi, GSorgu As String
Dim GKontrol1, GKontrol2
Dim rst As Recordset
GKontrol1 = False
GKontrol2 = False
GSorgu = "SELECT MSysObjects.Name FROM MSysObjects " & "WHERE Left$([Name],1)<>'~' AND Left$([Name],4)<>'MSys' " & "AND MSysObjects.Type =1 ORDER BY MSysObjects.Name"
Set rst = CurrentDb().OpenRecordset(GSorgu)
rst.MoveFirst
Do Until rst.EOF
If rst!Name = "Kişiler" Then
GKontrol1 = True
End If
If rst!Name = "bölümler" Then
GKontrol2 = True
End If
rst.MoveNext
Loop
If GKontrol1 = True Then
MsgBox ("Kişiler Tablosu Var")
Else
MsgBox ("Kişiler Tablosu Yok")
End If
If GKontrol2 = True Then
MsgBox ("bölümler Tablosu Var")
Else
MsgBox ("bölümler Tablosu Yok")
End If
rst.Close
Set rst = Nothing
Farklı veritabanı için
Dim cnnDB As ADODB.Connection
Dim rstList As ADODB.Recordset
Dim GKontrol1, GKontrol2
Dim GVeriTabani As String
GKontrol1 = False
GKontrol2 = False
GVeriTabani = "D:\Test\Test.mdb"
Set cnnDB = New ADODB.Connection
With cnnDB
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open GVeriTabani
End With
Set rstList = cnnDB.OpenSchema(adSchemaTables)
With rstList
Do While Not .EOF
If .Fields("TABLE_TYPE") <> "VIEW" And "Kişiler" = .Fields("TABLE_NAME") Then
GKontrol1 = True
End If
If .Fields("TABLE_TYPE") <> "VIEW" And "bölümler" = .Fields("TABLE_NAME") Then
GKontrol2 = True
End If
.MoveNext
Loop
If GKontrol1 = True Then
MsgBox ("Kişiler Tablosu Var")
Else
MsgBox ("Kişiler Tablosu Yok")
End If
If GKontrol2 = True Then
MsgBox ("bölümler Tablosu Var")
Else
MsgBox ("bölümler Tablosu Yok")
End If
End With
cnnDB.Close
Set cnnDB = Nothing