Checking if a Table Exists

B

Bas Cost Budde

Chaplain said:
How do I check programmatically to see if a table exists?
Thanks.

air code:

function isTable(cName as string) as boolean
dim td as tabledef
on error resume next
set td=currentdb.tabledefs(cname)
isTable=(err=0)
set td=nothing
end function
 
C

Cheryl Fischer

From a post dated 2/12/2004 by Access MVP Ken Snell:

This function will return a true value if the table exists in the database;
false if not.

Public Function TableIsHere(strTableName As String) As Boolean
Dim tdf As TableDef
TableIsHere = False
For Each tdf in CurrentDb.TableDefs
If tdf.Name = strTableName Then TableIsHere = True
Next tdf
End Function
 

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

Similar Threads

add field to table 2
Check if a table object exists 1
Lookup 4
Excel VBA 0
How to check if a query exists and if it finds to delete 3
Find exact Match 2
Deleting a Table if It Exists 5
Check if a table exists 5

Top