Option Compare Database Option Explicit Public Sub ExportAll(Optional ByVal newer_only As Boolean = False) logger "ExportAllSource", "INFO", "Begin 'Export all sources'" logger "ExportAllSource", "DEBUG", "> Newer only: " & newer_only ' try to save current project Call SaveProject ' close any opened form or report, except OpenAccess's form Call CloseFormsReports ' export database properties Call ExportProperties(CurrentDb, joinpaths(source_dir, "database.properties")) Call ExportAllQueries(newer_only) Call ExportAllDocs(acForm, newer_only) Call ExportAllDocs(acReport, newer_only) Call ExportAllDocs(acMacro, newer_only) Call ExportAllDocs(acModule, newer_only) Call ExportAllTables(newer_only) Call ExportReferences Call ExportAllRelations logger "ExportAll", "INFO", "Export done" End Sub Public Sub ExportAllQueries(Optional ByVal newer_only As Boolean = False) Dim dirpath As String Dim count, total As Integer Dim file_path As String Dim db As DAO.Database Set db = CurrentDb() Dim qry As Object dirpath = joinpaths(source_dir(), "queries\") mktree dirpath logger "ExportAllQueries", "INFO", "Export queries" logger "ExportAllQueries", "DEBUG", "> export to: " & dirpath logger "ExportAllQueries", "DEBUG", "> Newer only: " & newer_only count = 0 If newer_only Then total = UBound(Split(list_to_export(acQuery), ";")) + 1 Else total = db.QueryDefs.count End If For Each qry In db.QueryDefs If Left$(qry.name, 1) = "~" Then logger "ExportAllQueries", "DEBUG", "Query " & qry.name & " ignored" GoTo next_qry End If If newer_only Then If needs_export(acQuery, qry.name) = NoExportNeeded Then logger "ExportAllQueries", "DEBUG", "Query " & qry.name & " skipped" GoTo next_qry End If End If file_path = joinpaths(dirpath, to_filename(qry.name) & ".bas") ExportDocument acQuery, qry.name, file_path count = count + 1 Call SysCmd(acSysCmdSetStatus, "Export query: " & count & " on " & total) next_qry: Next Call SysCmd(acSysCmdClearStatus) logger "ExportAllQueries", "INFO", "> " & count & " queries exported" End Sub Public Sub ExportAllDocs(ByVal acType As Integer, Optional ByVal newer_only As Boolean = False) 'export all the documents of the acType Dim doc_label As String Dim dirpath As String Dim count, total As Integer Dim file_path As String Dim db As DAO.Database Set db = CurrentDb() Dim doc As Object 'get the document's container's name from it's type doc_label = get_container_name(acType) If Len(doc_label) = 0 Then logger "ExportAllDoc", "CRITICAL", "acType " & acType & " is not recognized!" Exit Sub End If dirpath = joinpaths(source_dir(), doc_label & "\") mktree dirpath logger "ExportAllDocs", "INFO", "# Export " & doc_label logger "ExportAllDocs", "DEBUG", "> export to: " & dirpath logger "ExportAllDocs", "DEBUG", "> newer only: " & newer_only count = 0 If newer_only Then total = UBound(Split(list_to_export(acType), ";")) + 1 Else total = db.Containers(doc_label).Documents.count End If For Each doc In db.Containers(doc_label).Documents If Left$(doc.name, 1) = "~" Then logger "ExportAllDocs", "DEBUG", doc_label & ": " & doc.name & " ignored" GoTo next_doc End If If newer_only Then If needs_export(acType, doc.name) = NoExportNeeded Then logger "ExportAllDocs", "DEBUG", doc_label & ": '" & doc.name & " skipped" GoTo next_doc End If End If file_path = joinpaths(dirpath, to_filename(doc.name) & ".bas") ExportDocument acType, doc.name, file_path If doc_label = "reports" Then file_path = joinpaths(dirpath, to_filename(doc.name) & ".pv") ExportPrintVars doc.name, file_path End If Call SysCmd(acSysCmdSetStatus, "Exporting " & doc_label & ": " & count & " on " & total) count = count + 1 next_doc: Next Call SysCmd(acSysCmdClearStatus) logger "ExportAllDocs", "INFO", "> " & count & " " & doc_label & " exported" End Sub Public Sub ExportAllTables(Optional ByVal newer_only As Boolean = False) 'export table definitions and data (if the table is in include_tables list) Dim dirpath As String Dim file_path As String Dim count As Integer Dim total As Integer Dim td As DAO.TableDef Dim tds As DAO.TableDefs Dim with_data As Boolean Dim db As DAO.Database Set db = CurrentDb() dirpath = joinpaths(source_dir(), "tables\") mktree dirpath logger "ExportAllTables", "INFO", "Export tabledefs" logger "ExportAllTables", "DEBUG", "> export to: " & dirpath logger "ExportAllTables", "DEBUG", "> Newer only: " & newer_only Set tds = db.TableDefs count = 0 If newer_only Then total = UBound(Split(list_to_export(acTable), ";")) + 1 Else total = tds.count End If Dim include_tables As String include_tables = get_include_tables() Dim IncludeTablesCol As Collection Set IncludeTablesCol = StrSetToCol(include_tables, ",") For Each td In tds If Left$(td.name, 1) = "~" Or Left$(td.name, 4) = "MSys" Then logger "ExportAllTables", "DEBUG", "tables: " & td.name & " ignored" GoTo next_td End If If newer_only Then If needs_export(acTable, td.name) = NoExportNeeded Then logger "ExportAllTables", "DEBUG", "tables: " & td.name & " skipped" GoTo next_td End If End If If Len(td.connect) = 0 Then ' this is not an external table with_data = (InCollection(IncludeTablesCol, td.name) Or include_tables = "*") ExportTable td.name, dirpath, with_data Else ExportLinkedTable td.name, dirpath End If count = count + 1 Call SysCmd(4, "Export table definition: " & count & " on " & total) next_td: Next Call SysCmd(acSysCmdClearStatus) logger "ExportAllTables", "INFO", "> " & count & " tbldefs exported" End Sub Public Sub ExportAllRelations() Dim dirpath, filePath As String Dim count, total As Integer dirpath = joinpaths(source_dir(), "relations\") mktree dirpath logger "ExportRelations", "INFO", "Export relations" logger "ExportRelations", "DEBUG", "> export to: " & dirpath count = 0 Dim aRelation As DAO.Relation total = CurrentDb.Relations.count For Each aRelation In CurrentDb.Relations ' Exclude relations from system tables and inherited (linked) relations If Not (aRelation.name = "MSysNavPaneGroupsMSysNavPaneGroupToObjects" _ Or aRelation.name = "MSysNavPaneGroupCategoriesMSysNavPaneGroups" _ Or (aRelation.Attributes And DAO.RelationAttributeEnum.dbRelationInherited) = _ DAO.RelationAttributeEnum.dbRelationInherited) Then filePath = joinpaths(dirpath, to_filename(aRelation.name) & ".txt") ExportRelation aRelation, filePath count = count + 1 Call SysCmd(4, "Export relation: " & count & " on " & total) End If Next Call SysCmd(acSysCmdClearStatus) logger "ExportAllSource", "INFO", "> " & count & " relations exported" End Sub