|
-
May 13th, 2001, 03:33 PM
#1
How do I determine if a table exists in Acess DB
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
-
May 14th, 2001, 01:25 AM
#2
Re: How do I determine if a table exists in Acess DB
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
[email protected]
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
-
May 14th, 2001, 04:03 AM
#3
Re: How do I determine if a table exists in Acess DB
Thanks, I'll give it a whirl
John lamb
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|