Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Contribution: doesTableExist()

Status
Not open for further replies.

waldemar

Programmer
Nov 15, 2001
245
DE
I found so many helping hands in this forum, I guess it's just about time to start contributing results...

This function is useful for people you work with dynamic external table linking... simply returns TRUE or FALSE if an internal (strDBPath="") or external (strDBPath = PathToExternalDatabase) table exists...

Function doesTableExist(strDBPath As String, tblTable As String) As Boolean
' ----- DOES THIS INTERNAL OR EXTERNAL TABLE EXIST? ------
Dim db As Database
Dim counter As Integer
startFunction:
On Error GoTo errHandler

If strDBPath = "" Then Set db = CurrentDb Else Set db = DBEngine.OpenDatabase(strDBPath)
doesTableExist = False
db.TableDefs.Refresh
For counter = 0 To db.TableDefs.Count - 1
If tblTable = db.TableDefs(counter).Name Then
doesTableExist = True
Exit For
End If
Next counter
Set db = Nothing

exitFunction:
Exit Function
errHandler:
' Error Handling
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top