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 generation. It’s an ideal candidate for Access.
I want to make changes to the table design, the VBA, the queries, and the forms. How can I track my changes with version control? (we use Subversion, but this goes for any flavor) I can stick the entire mdb in subversion, but that will be storing a binary file, and I won’t be able to tell that I just changed one line of VBA code.
I thought about copying the VBA code to separate files, and saving those, but I could see those quickly getting out of sync with what’s in the database.
We wrote our own script in VBScript, that uses the undocumented Application.SaveAsText() in Access to export all code, form, macro and report modules. Here it is, it should give you some pointers. (Beware: some of the messages are in german, but you can easily change that.)
EDIT: To summarize various comments below:
Our Project assumes an .adp-file. In order to get this work with .mdb/.accdb, you have to change OpenAccessProject() to OpenCurrentDatabase(). (Updated to useOpenAccessProject()if it sees a .adp extension, else useOpenCurrentDatabase().)decompose.vbs:
If you need a clickable Command, instead of using the command line, create a file named ‘decompose.cmd’ with
By default, all exported files go into a ‘Scripts’ subfolder of your Access-application. The .adp/mdb file is also copied to this location (with a ‘stub’ suffix) and stripped of all the exported modules, making it really small.
You MUST checkin this stub with the source-files, because most access settings and custom menu-bars cannot be exported any other way. Just be sure to commit changes to this file only, if you really changed some setting or menu.
Note: If you have any Autoexec-Makros defined in your Application, you may have to hold the Shift-key when you invoke the decompose to prevent it from executing and interfering with the export!
Of course, there is also the reverse script, to build the Application from the ‘Source’-Directory:
compose.vbs:
Again, this goes with a companion ‘compose.cmd’ containing:
It asks you to confirm overwriting your current application and first creates a backup, if you do. It then collects all source-files in the Source-Directory and re-inserts them into the stub.
Have Fun!