Click to See Complete Forum and Search --> : How do I determine if a table exists in Acess DB
John_Lamb
May 13th, 2001, 03:33 PM
I would like to determine if a table exists in an Access database from my VB application using DAO. I can delete a table even copy from another database, but I'm having a problem doing this one.
Help appreciated
Cakkie
May 14th, 2001, 01:25 AM
You can do this on two ways
The quick and dirty way: you just try to access the table and look if an error has occured
dim TD as TableDef
on error resume next
set TD = DB.TableDefs("MyTable")
If Err.Number <> 0 then
'Table does not exist
else
' Table exists
End If
or you can do it the nice (but mostly a wee bit slower), just enumerate throug the tables an see if the name matches
Dim TD as TableDef
for Each TD in DB.TableDefs
If TD.Name = "myTable" then
' we found it
End If
next TD
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
John_Lamb
May 14th, 2001, 04:03 AM
Thanks, I'll give it a whirl
John lamb
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.