Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Application.CurrentProject.AllForms("Form1").IsLoaded
Option Compare Database
Option Explicit
'objectExists()
'
'For tables, queries and modules, this function returns true if they EXIST.
'For forms and reports, this function returns true if they are OPEN.
Public Function objectExists(objType As String, objName As String) As Boolean
Select Case objType
Case acTable
objectExists = tableExists(objName)
Case acQuery
objectExists = queryExists(objName)
Case acForm
objectExists = formExists(objName)
Case acReport
objectExists = reportExists(objName)
Case acModule
objectExists = moduleExists(objName)
Case Else
objectExists = False
End Select
End Function
Public Function tableExists(tableName As String) As Boolean
On Error GoTo sub_Error
Dim tmp As String
tmp = DBEngine(0)(0).TableDefs(tableName).Name
tableExists = True
sub_Exit:
Exit Function
sub_Error:
tableExists = False
GoTo sub_Exit
End Function
Public Function queryExists(queryName As String) As Boolean
On Error GoTo sub_Error
Dim tmp As String
tmp = DBEngine(0)(0).QueryDefs(queryName).Name
queryExists = True
sub_Exit:
Exit Function
sub_Error:
queryExists = False
GoTo sub_Exit
End Function
Public Function formExists(formName As String) As Boolean
On Error GoTo sub_Error
Dim tmp As String
tmp = Forms(formName).Name
formExists = True
sub_Exit:
Exit Function
sub_Error:
formExists = False
GoTo sub_Exit
End Function
Public Function reportExists(reportName As String) As Boolean
On Error GoTo sub_Error
Dim tmp As String
tmp = Reports(reportName).Name
reportExists = True
sub_Exit:
Exit Function
sub_Error:
reportExists = False
GoTo sub_Exit
End Function
Public Function moduleExists(moduleName As String) As Boolean
On Error GoTo sub_Error
Dim tmp As String
tmp = Modules(moduleName).Name
moduleName = True
sub_Exit:
Exit Function
sub_Error:
moduleName = False
GoTo sub_Exit
End Function