How to Use:Code:Option Explicit Sub TableExits(strDBPath As String, strTable As String) Dim adoConn As Object Dim rstRec As Object Set adoConn = CreateObject("ADODB.Connection") Set rstRec = CreateObject("ADODB.Recordset") adoConn.Open "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & strDBPath & ";" On Error GoTo xxx: rstRec.Open "Select * from " & strTable, adoConn, 3, 3 xxx: If Err.Number = -2147217865 Then MsgBox "Table does not Exist.", vbInformation, "Table Exists or Not" Else MsgBox "Table Exists.", vbInformation, "Table Exists or Not" End If End Sub
Code:Sub test() Dim strDBPath As String Dim strTable As String '===========DB Path====== strDBPath = "K:\xys\XYZDB.mdb" '======================= '=====Table Name========= strTable = "abc" '======================= Call TableExits(strDBPath, strTable) End Sub


Reply With Quote

Bookmarks