Testing for table existence 
Author Message
 Testing for table existence

I have created a table in an mdb using the CREATE TABLE sql statement.

How do I test for a particular table name and then delete it if it exists?

Thanks

(reply to newgroup and author please)

Ken



Fri, 09 Feb 2001 03:00:00 GMT  
 Testing for table existence

Quote:
>I have created a table in an mdb using the CREATE TABLE sql statement.

>How do I test for a particular table name and then delete it if it exists?

>Thanks

>(reply to newgroup and author please)

>Ken

Use the TableDefs object

where db is your database

for x = 0 to db.TableDefs.Count
    If db.TableDefs(x).Name="SomeName" Then
        'Yes you found it
    else
        'You did not
    end if
next x

Clint LaFever
Software Engineer
SAIC (http://www.saic.com)

---------------------------------------------
(Personal)

http://lafever.home.ml.org



Fri, 09 Feb 2001 03:00:00 GMT  
 Testing for table existence

Quote:

> I have created a table in an mdb using the CREATE TABLE sql statement.

> How do I test for a particular table name and then delete it if it exists?

> Thanks

> (reply to newgroup and author please)

> Ken

try using table defs collection thus

Dim DB as Database
Dim tbldef as tabledef

For each tbldef in DB.tabledefs
        if tbldef.name="TargetTable" Then
                'delete table
                DB.Tabledefs.Delete tbldef.name                
                Exit for
        Endif  
Next



Sat, 10 Feb 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Testing for table existence & listing available tables

2. Test for table existence

3. Testing for table existence

4. Testing for table existence

5. Testing for table existence

6. Testing for Existence of Table

7. Test for the existence of a table

8. Testing the existence of a table

9. TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST

10. Testing for existence of a query

11. Testing for a record already in existence

12. test for existence of a field

 

 
Powered by phpBB® Forum Software