How to know if table exists? 
Author Message
 How to know if table exists?

In Access database I use One table as temporary(fields always different)
Some time User can interrupt program and this table steel be in DB.
I don't like use On Error...
Can I check if this table exists?


Fri, 07 Nov 2003 22:03:25 GMT  
 How to know if table exists?
this procedure finds the tables in a database and and puts their names  into
a combobox
cbotables hope this helps

Public Sub openschemax_tablenames(ByRef db_name As String)
'******************************************************************'
' Procedure for listing non system tables in database using
' openschema method
'*********************************************************************

    Dim conxn As ADODB.Connection
    Dim rsschema As ADODB.Recordset
    Dim conxstr As String
    Dim ndata As String
    Set conxn = New ADODB.Connection

ndata = "Data Source=" & db_name & ";"
conxstr = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& ndata & "Persist Security Info=False"
    conxn.Open conxstr
    cbotables.Clear
    Set rsschema = conxn.OpenSchema(adSchemaTables)

    Do Until rsschema.EOF
        ' if not a sytem table shows the table in the combobox
        If Not rsschema!TABLE_TYPE = "SYSTEM TABLE" Then

            cbotables.AddItem rsschema!TABLE_TYPE & ":" &
rsschema!TABLE_NAME
            rsschema.MoveNext
        Else
            rsschema.MoveNext
        End If
    Loop

    rsschema.Close
    conxn.Close
    Set rsschema = Nothing
    Set conxn = Nothing

--
Shaun Hare


Quote:
> In Access database I use One table as temporary(fields always different)
> Some time User can interrupt program and this table steel be in DB.
> I don't like use On Error...
> Can I check if this table exists?



Fri, 07 Nov 2003 22:26:32 GMT  
 How to know if table exists?
On Mon, 21 May 2001 09:03:25 -0500, "Ivan Demkovitch"

you can use the tabeldef

Quote:
>In Access database I use One table as temporary(fields always different)
>Some time User can interrupt program and this table steel be in DB.
>I don't like use On Error...
>Can I check if this table exists?



Sat, 08 Nov 2003 07:26:13 GMT  
 How to know if table exists?

Quote:

> In Access database I use One table as temporary(fields always different)
> Some time User can interrupt program and this table steel be in DB.
> I don't like use On Error...
> Can I check if this table exists?

While you could loop through the DAO.Database.TableDefs collection, you
do need to become comfortable with error handling if you ever want to
deploy an EXE, DLL, OCX, or Access MDE. My usual style is to avoid error handling if at all possible, but it is needed in database
code to clean
up objects, rollback transactions, or perhaps delete a stale temporary
table and attempt to resume.

--

WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Sun, 09 Nov 2003 04:49:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to modified existing field and add new field in existing table for Access database

2. Create new field in existing table exactly like field in second table

3. Problem with creating a table in Access from existing table

4. Possible to know if directory exists already ?

5. Collection Objects: How to know if a single item exists

6. How to know if a file exist?

7. How to know if a file exist?

8. How to know if a file exist? - better

9. How can i know if a file exist????

10. How to know if active Winsock connection exists?

11. need to know if an add on exists...

12. How to know if a variable exists in a collection in JScript

 

 
Powered by phpBB® Forum Software