PC Review


Reply
Thread Tools Rate Thread

How can I use VBA ADO to check if a table exists in an Access DB?

 
 
Ai_Jun_Zhang
Guest
Posts: n/a
 
      23rd Aug 2005

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

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      23rd Aug 2005
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
>



 
Reply With Quote
 
Ai_Jun_Zhang
Guest
Posts: n/a
 
      24th Aug 2005

Thanks, Bob. It works and I really appreciate your help.

Bob, I have a side question. Is there any way this forum can notify me
by email if somebody has responded to my question? It will be very
convenient for me. Otherwise, as I am doing now, I have to check the
forum periodically to see if anybody has responded to my email.

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

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      24th Aug 2005
Hi Aijun,

I am afraid that I cannot help you with that question. I do not subscribe to
the forum, I connect to the Microsoft public newsgroups, where questions on
your forum are forwarded to. You would need to raise it there, but my
experience is that it's all or noting with these forums, you get an email
about all posts, or none.

Sorry I could not help more.

Bob


"Ai_Jun_Zhang" <(E-Mail Removed)>
wrote in message
news:(E-Mail Removed)...
>
> Thanks, Bob. It works and I really appreciate your help.
>
> Bob, I have a side question. Is there any way this forum can notify me
> by email if somebody has responded to my question? It will be very
> convenient for me. Otherwise, as I am doing now, I have to check the
> forum periodically to see if anybody has responded to my email.
>
> 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
>




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check to see if the data already exists in the table in Access matrix7410@yahoo.com Microsoft Access Reports 3 22nd Oct 2008 10:20 PM
How can I check if a table exists in Access 2002 using VB =?Utf-8?B?Sm8gTQ==?= Microsoft Access VBA Modules 6 28th Nov 2005 05:39 PM
RE: How can I use VBA ADO to check if a table exists in an Access DB? =?Utf-8?B?Um93YW4=?= Microsoft Excel Programming 0 23rd Aug 2005 04:23 AM
how to check if table exists in Access with ADO? Billy Microsoft Access VBA Modules 1 4th May 2004 05:41 PM
How to check if a table exists in Access XP Anthony Bowman Microsoft VB .NET 3 4th Nov 2003 07:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:51 PM.