is table already created

P

Pierre

Hi all,

In a big mdb files, i want to create a table.
If the table already exist i want to erase it before.

My problem is i want to know if the table exist before deleting it.

I dont want to delete it and do error processing if the table does not
exist.

i dont want to cycle through the tabledefs collection (too long) to see if
it exist.

i would like to use a properties like exist or so to find if the table is
created

Is there something to tell you that and object exist?

regards,
pierre
 
D

Dirk Goldgar

Pierre said:
Hi all,

In a big mdb files, i want to create a table.
If the table already exist i want to erase it before.

My problem is i want to know if the table exist before deleting it.

I dont want to delete it and do error processing if the table does not
exist.

Why not? It's the most efficient way that doesn't depend on the
internal structure of the MDB file.
i dont want to cycle through the tabledefs collection (too long) to
see if it exist.

Why not? It's very fast.
i would like to use a properties like exist or so to find if the
table is created

There is no such property.
Is there something to tell you that and object exist?

If you are willing to rely on the internal structures of the Jet
database format -- and you can probably rely on these not changing,
though Microsoft won't promise you that -- then you can query the
MSysObjects table directly, either by opening a recordset on a query or
by using one of the domain aggregate functions such as DLookup or
DCount. For example,

If DCount("*", "MSysObjects", _
"[name] = 'MyTable' AND [Type] In (1, 6)") _
Then
DoCmd.DeleteObject acTable, "MyTable"
End If

Object types 1 and 6 are local tables and linked tables, respectively.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top