checking to see if a table exists.

ducker

across the pond
Local time
Today, 14:44
Joined
Jan 6, 2005
Messages
55
I'm running the following line:

dbs.Execute ("DROP TABLE [tbl_No Certs]")


the problem is that sometimes the table doesn't exist... Instead of trapping the error code, is there a way I can check to see if the table exists? If it doesn't I'll simply skip this step of my code and move on.

Thanks!
 
Function Check_4_table(tbl_name As String) As Boolean
Dim db As Database, LP As Integer, td As TableDef
' Return reference to current database.
Set db = CurrentDb
For Each td In db.TableDefs
If UCase(tbl_name) = UCase(td.Name) Then
Check_4_table = True
Exit Function
Else
MsgBox td.Name, , "Testing"
End If
Next
Set db = Nothing
End Function

Useage:
IF Check_4_Table("tableName") then
' Yes table exist
ELSE
' No it does not
END iF
 
AWESOME! thanks a ton!
 

Users who are viewing this thread

Back
Top Bottom