Create the Client Application
The hard part is done - we just need to hook it up into a client application. Start by creating a new database called ClientApp.accdb. Create the AppVersion property in this database as follows:
- Click the Office menu and choose Manage; then click Database Properties.
- Choose the Custom tab in the Properties dialog box.
- Type AppVersion in the Name text box.
- Type 1.0 in the Value text box, and then click Add. Click OK to close the dialog box.
Next, create a new form called frmCheckVersion and add the following code to the Load event of the form.
Private Sub Form_Load() Dim obj As Access.Application Dim upd As Object
We're going to automate the versioning server to get an instance of the Updater class. To do this, we need to run code in this database. Launch a new instance of Access and set the AutomationSecurity property of the new instance to allow code to run:
Set obj = New Access.Application obj.AutomationSecurity = 1
Next, open the versioning server and hide it. Change the path to the versioning server on your computer.
obj.OpenCurrentDatabase "<PathTo>\VersioningServer.accdb" obj.Visible = False
Because the client application doesn't have a class module called Updater, we're using late binding to the Updater class in the versioning server. Remember that the server application has a function called GetUpdaterInstance to give us an instance of this class. Add the following code to get a late-bound instance of the Updater class and set the ApplicationDatabase property:
' get the object Set upd = obj.Run("GetUpdaterInstance") upd.ApplicationDatabase = CurrentDb.Name
Last, use the IsLatestVersion function in the class to determine whether the client is running the latest version. If it is not, call the StartUpdate method of the Updater class in the server application. If the client is running the latest version, we'll display the version number from the AppVersion property and close the frmCheckVersion form.
If (Not upd.IsLatestVersion) Then ' start the update - sets the timer interval of frmTimer upd.StartUpdate ' close this database Application.Quit acQuitSaveNone Else MsgBox "You are running version: " & _ CurrentDb.Containers("Databases").Documents("UserDefined").Properties("AppVersion") DoCmd.Close acForm, Me.Name End If End Sub
In this tutorial:
- Creating an Automated Build
- Design the Form
- Retrieving Information from the Source Database
- Building the Application
- Creating the Target Database
- Set Build Properties on the Target Database
- Setting Build Properties on the Source Database
- Deleting Data from Tables
- Calculating the Version Number
- Handling Application Dependencies
- Updating References
- Testing Reference Fix-Up
- Late Binding
- Licensing Your Applications
- Number of Records
- Restricting the Number of Times an Application is Launched
- Registering an Application
- Creating a Registration Web Service
- Validate the Registration Using the Web Service
- Miscellaneous Deployment Scenarios
- Create the Client Application
- Testing the Versioning Server
- Re-Linking Tables Automatically
- Programmatically Creating DSNs
- Creating a User DSN
- Ensuring an Application Runs Locally