Here is an Access VB routine to check for the existence of an object in the MS Access database:' Pass the Object type: Table, Query, Form, Report, Macro, or Module' Pass the Object NameFunction ObjectExists(strObjectType As String, strObjectName As String) As Boolean Dim db As Database Dim tbl As TableDef Dim qry As QueryDef Dim i As Integer Set db = CurrentDb() ObjectExists = False If strObjectType = "Table" Then For Each tbl In db.TableDefs If tbl.NAME = strObjectName Then ObjectExists = True Exit Function End If Next tbl ElseIf strObjectType = "Query" Then For Each qry In db.QueryDefs If qry.NAME = strObjectName Then ObjectExists = True Exit Function End If Next qry ElseIf strObjectType = "Form" Or strObjectType = "Report" Or strObjectType = "Module" Then For i = 0 To db.Containers(strObjectType & "s").Documents.Count - 1 If db.Containers(strObjectType & "s").Documents(i).NAME = strObjectName Then ObjectExists = True Exit Function End If Next i ElseIf strObjectType = "Macro" Then For i = 0 To db.Containers("Scripts").Documents.Count - 1 If db.Containers("Scripts").Documents(i).NAME = strObjectName Then ObjectExists = True Exit Function End If Next i Else MsgBox "Invalid Object Type passed, must be Table, Query, Form, Report, Macro, or Module" End If End Function
The only problem with this for you would be that the CurrentDB() function would have to be replaced with an object reference bound to the Access database.--SMerrillSeattle, WA