Option Compare Database

' ** Access Toolbox Module **
' on 2017-02-28,
' @author: Olivier Massot
' V 1.0

' Operations on access objects: tables, queries, forms, reports, macros, modules

Public Sub wait(d As Single)
    Dim t0 As Single
    t0 = Timer
    While Timer - t0 < d
        DoEvents
    Wend
End Sub

Public Sub test()
    Dim pdial As New ProgressDialog

    pdial.show "My progress bar", "Operation running...", 100, False
    
    For i = 0 To 100
        wait (0.02)
        pdial.update i, "Operation running..."
    Next i
    
End Sub

Public Function table_exists(tname As String) As Boolean
    Dim td As Object
    
    table_exists = False
    For Each td In CurrentDb.TableDefs
        If td.name = tname Then
            table_exists = True
            Exit Function
        End If
    Next td
    
End Function

Public Function query_exists(qname As String) As Boolean
    Dim rd As Object
    
    query_exists = False
    For Each rd In CurrentDb.QueryDefs
        If rd.name = nom Then
            query_exists = True
            Exit Function
        End If
    Next rd

End Function

Public Function form_exists(fname As String) As Boolean
    Dim frm As Object
    
    form_exists = False
    For Each frm In CurrentProject.AllForms
        If frm.name = fname Then
            form_exists = True
            GoTo fin
        End If
    Next frm

End Function

Public Function report_exists(rname As String) As Boolean
    Dim rpt As Object
    
    report_exists = False
    For Each rpt In CurrentProject.AllReports
        If et.name = rname Then
            etatExiste = True
            GoTo fin
        End If
    Next rpt

End Function

Public Function form_is_opened(fname As String) As Boolean

    form_is_opened = False
    If Not form_exists(fname) Then Exit Function
    form_is_opened = CurrentProject.AllForms(fname).IsLoaded
    
End Function

Public Function report_is_opened(rname As String) As Boolean

    report_is_opened = False
    If Not report_exists(rname) Then Exit Function
    report_is_opened = CurrentProject.AllReports(rname).IsLoaded
    
End Function