Determine if a table exsists

jstutz

Registered User.
Local time
Today, 12:10
Joined
Jan 28, 2000
Messages
80
I am writing some code that updates a group of tables by deleting the old ones and then creating new ones using some MakeTable queries.

My question is this: Is there some code I can use to determine if the table already exists? Basically, I want to add an If/Then statement that checks to see if the table is there and if it is, delete it and if it isn't, just run the MakeTable query.

I think this is probably easy, but I just couldn't find what I was looking for in the help files.

Thanks!

Jamie
 
Try this:

Public Function DoesTableExist(ByVal stTableName) as boolean
on error resume next
if Currentdb.tableDefs(stTableName).Name = stTableName then DoesTableExist = True
if Err<>0 then DoesTableExist = False
'Error 3265 is the error you are looking for if the table is not in your DB.
end Function
 
Thanks!
 

Users who are viewing this thread

Back
Top Bottom