How do you use version control with Access development?

后端 未结 20 1726
慢半拍i
慢半拍i 2020-11-22 12:55

I\'m involved with updating an Access solution. It has a good amount of VBA, a number of queries, a small amount of tables, and a few forms for data entry & report gene

20条回答
  •  花落未央
    2020-11-22 13:12

    Olivers answer rocks, but the CurrentProject reference was not working for me. I ended up ripping the guts out of the middle of his export and replacing it with this, based on a similar solution by Arvin Meyer. Has the advantage of exporting Queries if you are using an mdb instead of an adp.

    ' Writes database componenets to a series of text files
    ' @author  Arvin Meyer
    ' @date    June 02, 1999
    Function DocDatabase(oApp)
        Dim dbs 
        Dim cnt 
        Dim doc 
        Dim i
        Dim prefix
        Dim dctDelete
        Dim docName
    
        Const acQuery = 1
    
        Set dctDelete = CreateObject("Scripting.Dictionary")
    
        Set dbs = oApp.CurrentDb() ' use CurrentDb() to refresh Collections
        Set cnt = dbs.Containers("Forms")
        prefix = oApp.CurrentProject.Path & "\"
        For Each doc In cnt.Documents
            oApp.SaveAsText acForm, doc.Name, prefix & doc.Name & ".frm"
            dctDelete.Add "frm_" & doc.Name, acForm
        Next
    
        Set cnt = dbs.Containers("Reports")
        For Each doc In cnt.Documents
            oApp.SaveAsText acReport, doc.Name, prefix & doc.Name & ".rpt"
            dctDelete.Add "rpt_" & doc.Name, acReport
        Next
    
        Set cnt = dbs.Containers("Scripts")
        For Each doc In cnt.Documents
            oApp.SaveAsText acMacro, doc.Name, prefix & doc.Name & ".vbs"
            dctDelete.Add "vbs_" & doc.Name, acMacro
        Next
    
        Set cnt = dbs.Containers("Modules")
        For Each doc In cnt.Documents
            oApp.SaveAsText acModule, doc.Name, prefix & doc.Name & ".bas"
            dctDelete.Add "bas_" & doc.Name, acModule
        Next
    
        For i = 0 To dbs.QueryDefs.Count - 1
            oApp.SaveAsText acQuery, dbs.QueryDefs(i).Name, prefix & dbs.QueryDefs(i).Name & ".txt"
            dctDelete.Add "qry_" & dbs.QueryDefs(i).Name, acQuery
        Next
    
        WScript.Echo "deleting " & dctDelete.Count & " objects."
        For Each docName In dctDelete
            WScript.Echo "  " & Mid(docName, 5)
            oApp.DoCmd.DeleteObject dctDelete(docName), Mid(docName, 5)
        Next
    
        Set doc = Nothing
        Set cnt = Nothing
        Set dbs = Nothing
        Set dctDelete = Nothing
    
    End Function
    

提交回复
热议问题