Testing the existence of a table 
Author Message
 Testing the existence of a table

Hello,

In VBA under Access97, I'm using the function 'currentDB'.
With that, how is it possible to check whether a table 'myTable' exists
in the current database ?

Thank you very much

Nicolas Ecarnot

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 18 May 2003 03:00:00 GMT  
 Testing the existence of a table
Easiest way is to reference the table, and trap the error (3265)

Otherwise, try a function like:

Function TableExists(TableName As String) As Boolean
Dim dbCurr As Database
Dim intLoop As Integer

    TableExists = False

    Set dbCurr = CurrentDb()
    For intLoop = 0 To (dbCurr.TableDefs.Count - 1)
        If dbCurr.TableDefs(intLoop).Name = TableName Then
            TableExists = True
            Exit For
        End If
    Next

End Function

HTH

--

Doug Steele, Microsoft Access MVP
Beer, Wine and Database Programming. What could be better?
Visit "Doug Steele's Beer and Programming Emporium"
http://I.Am/DougSteele/


Quote:
> Hello,

> In VBA under Access97, I'm using the function 'currentDB'.
> With that, how is it possible to check whether a table 'myTable' exists
> in the current database ?

> Thank you very much

> Nicolas Ecarnot

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 18 May 2003 03:00:00 GMT  
 Testing the existence of a table


Thank you very much : it's working fine.

--

The sum of CPU power and user brain power is a constant.



Mon, 19 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Testing for table existence & listing available tables

2. How do I test the existence of a table.

3. Testing for Existence of Table

4. Test for table existence

5. Test for the existence of a table

6. Testing for table existence

7. Testing for table existence

8. Testing for table existence

9. Testing for table existence

10. TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST

11. Testing for existence of a query

12. Testing for a record already in existence

 

 
Powered by phpBB® Forum Software