View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
michelxld[_24_] michelxld[_24_] is offline
external usenet poster
 
Posts: 1
Default How can I use VBA ADO to check if a table exists in an Access DB?


Hello Aijun

this macro list the Access tables . you may use it to check if a tabl
exist
i hope this help you


Sub ListTables()
Dim Conn As ADODB.Connection
Dim rsT As ADODB.Recordset

Set Conn = New ADODB.Connection
With Conn
.Provider = "Microsoft.JET.OLEDB.4.0"
.Open ThisWorkbook.Path & "C:\MaBase_V01.mdb"
End With

Set rsT = Conn.OpenSchema(adSchemaTables)

While Not rsT.EOF
If rsT.Fields("TABLE_TYPE") = "TABLE" Then _
Debug.Print rsT.Fields("TABLE_NAME")

rsT.MoveNext
Wend

Set rsT = Nothing
Conn.Close
End Sub



regards
miche

--
michelxl
-----------------------------------------------------------------------
michelxld's Profile: http://www.excelforum.com/member.php...fo&userid=1736
View this thread: http://www.excelforum.com/showthread.php?threadid=39799