delete table if existis ado and vb6

User avatar
sal21
PlatinumLounger
Posts: 4368
Joined: 26 Apr 2010, 17:36

delete table if existis ado and vb6

Post by sal21 »

I need a code to loop in all tables of access database and delete table if existis...
Possible?

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: delete table if existis ado and vb6

Post by HansV »

Are there relationships with enforced referential integrity between the tables in the database?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4368
Joined: 26 Apr 2010, 17:36

Re: delete table if existis ado and vb6

Post by sal21 »

HansV wrote:Are there relationships with enforced referential integrity between the tables in the database?
no... is sample service table

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: delete table if existis ado and vb6

Post by HansV »

Do you want to delete a specific table or do you want to delete all tables?
Do you want to do this within Access or from Excel?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4368
Joined: 26 Apr 2010, 17:36

Re: delete table if existis ado and vb6

Post by sal21 »

HansV wrote:Do you want to delete a specific table or do you want to delete all tables?
Do you want to do this within Access or from Excel?
one table...
Example:

loop in all tables in mdb access anf if MyTable exists delete it.

I need in vba for excel or vb classic.
I just have active conn on access database named CN

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: delete table if existis ado and vb6

Post by HansV »

Try this:

On Error Resume Next
CN.Execute "DROP TABLE MyTable"
On Error GoTo 0
Best wishes,
Hans