If you want to Check the particular table is exist in Access Database or Not You Can use this Function :
Option Compare Text
Sub IsExist()
Dim cn As ADODB.Connection
Dim rst As Recordset
Dim MyConn As String
MyConn = "D:\MyDataBase.accdb"
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.ace.Oledb.12.0"
.Open MyConn
End With
Set rst = cn.OpenSchema(adSchemaTables)
rst.MoveFirst
Do Until rst.EOF
If rst!Table_Name = "MyTable1" Then
MsgBox "Table Exist "
Exit Do
End If
rst.MoveNext
Loop
rst.Close
cn.Close
End Sub
Option Compare Text
Sub IsExist()
Dim cn As ADODB.Connection
Dim rst As Recordset
Dim MyConn As String
MyConn = "D:\MyDataBase.accdb"
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.ace.Oledb.12.0"
.Open MyConn
End With
Set rst = cn.OpenSchema(adSchemaTables)
rst.MoveFirst
Do Until rst.EOF
If rst!Table_Name = "MyTable1" Then
MsgBox "Table Exist "
Exit Do
End If
rst.MoveNext
Loop
rst.Close
cn.Close
End Sub
No comments:
Post a Comment