Front End Version Control
Overview
The following describes the methods the associated files use to deploy a front end to local workstations. There are two files; the sample front end (MyDataBaseFE.mdb) and the 'loader' file (MyDataBase.mdb). A back end is not considered in these samples. Any method used to link to a back end from the front end should work.
The use of the two files are simple. You make some minor changes to the loader so that it knows what the file names are and where they are located. Then send it to the end user to copy to their desk top. When they want to run your application this is the file they execute. The front end is copied to the server. This server copy is now referred to as the master front end. When you have a new version of the front end, you delete the old one on the server, put the new one in its place and go into it and change the version number. The next time the user runs your application, if there is a new version, it gets copied to their local workstation and is opened.
The Database Property
The master front end really needs only one element to make it work: a database property called 'DatabaseVersion'. By default an MS Access database file does not contain this property so it must be created. The form 'zfrmVersionControl' will create it automatically when it is opened if it does not already exist and assign it a value of '01'. This default value of '01' can be changed in the code'. In addition to creating and assigning the initial value, zfrmVersionControl is used to update it. It can take any format desired as it is simply a text data type. So the version format you use can be '1' or '1.1' or even 'V1.1'.
The Loader File
The loader file has one code module called 'basVersionControl'. In it a function called 'fncVersionControlStartup' is called from the autoexec macro when it is opened. When executed it checks to see if the front end exists on the local workstation. If not it copies it over, opens it and closes itself. If the front end does exist then it compares the 'DatabaseVersion' values between the local copy of the front end and the master front end on the server. If they are different it deletes the front end on the local workstation, copies over the master front end from the server, opens it and closes itself. If a copy of the front end does exist on the local workstation and the 'DatabaseVersion' values are the same then it simply opens it and closes itself.
To set up the loader file go into the module 'basVersionControl' and change the following constants:
Code:
'Configure these==========================
'Front end file name
Const cstrFEFile = "MYDatabaseFE.mdb"
'Location of master FE file on server
Const cstrMasterFEPath = "I:\MySharedFolder\"
'Location of FE on local machine
Const cstrClientFEPath = "C:\LocalFiles\"
'Location of MS Access .exe
Const cstrMSAccessAPP = "C:\Program Files\Microsoft Office\Office11\MSACCESS.exe"
'=====================================
The code comments are self explanatory. The destination of the front end should already exist on each workstation.
The remaining functions and procedures in the module 'basVersionControl' are called from within the module.
The Front End File
The sample front end file has three objects; The forms 'zfrmVersionControl' (described above) and 'frmStartUp' and a code module called 'abasStartUpRoutines'.
The form 'frmStart' is simply a sample start up form which happens to have a text box control that displays the current 'DatabaseVersion' property value.
The code module 'abasStartUpRoutines' does two things, neither are required for the front end loader to work. It contains one function called 'fncStartUpRoutine' which is called by the autoexec macro when the database is opened. The first thing it does is check to see if the database has been opened by the loader to prevent a user from opening the front end directly. This is done by checking to see if the correct command line parameter has been passed to the database when it was opened. To do this the front end the loader file builds a command line string similar to the one below. The command line switch '/cmd "MyTokenValue"' passes the command line parameter to the front end:
Code:
C:\Program Files\Microsoft Office\Office11\MSACCESS.exe /cmd "MyTokenValue" "C:\LocalFiles\FE.mdb"
Then when the front end opens, the following line of code checks to see if it exists:
Code:
If IsNull(Command) Or Command <> "MyTokenValue" Then
If this evaluates to true then the code simply proceeds to the next step which is to open the startup form. If it is false the it advises the user of the condition and exits the database.
Again, this is secondary functionality in these sample files and not required. The only thing that is required in the front end is the database property called 'DatabaseVersion'.
The shift key should be disabled to prevent the user from by passing this functionality. Since this functionality does exist in the sample front end file you will have to hold down the shift key to get to the objects.
Summary
Modify the loader file so that it knows what the file names are and where they are located and send it to the end user. Copy the form zfrmVersionControl into your front end and set up the database version number. Put the front end on the server and you are done. When you have a new front end, change the version number in it and copy it to the server deleting the old one.