Here is a simple function. Call with
?IfTableExists("C:\temp\MtDB.mdb","DB")
Function IfTableExists(FileName As String, Table As String) As Boolean
Dim oConn As Object
Set oConn = CreateObject("ADODB.Connection")
oConn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
FileName
On Error Resume Next
oConn.Execute "SELECT 1 FROM [" & Table & "] WHERE 0=1"
IfTableExists = (Err.Number = 0)
oConn.Close
Set oConn = Nothing
End Function
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Ai_Jun_Zhang" <(E-Mail Removed)>
wrote in message
news:(E-Mail Removed)...
>
> Hi!
>
> If I aready have an access DB called c:\temp\MyDb.mdb, is there any way
> that I can use ADO to check if a table exists in this database?
>
> Thanks,
>
> Aijun.
>
>
> --
> Ai_Jun_Zhang
> ------------------------------------------------------------------------
> Ai_Jun_Zhang's Profile:
http://www.excelforum.com/member.php...o&userid=25474
> View this thread: http://www.excelforum.com/showthread...hreadid=397998
>