Beruflich Dokumente
Kultur Dokumente
Page 1 of 8
Contents
Introduction Running in Runtime vs. Full Access 2003 Creating User Interface Objects Setting Startup Options Error Handling in VBA Code Protecting Your Code with MDE Files Streamlining the Distribution Process with the Access 2003 Developer Extensions Tools Conclusion
Introduction
Legend has it that some developers of business applications work in environments where all the computers run the sameand latestversion of all software. Here in the real world, though, it is rather common for Microsoft Office Access developers to create applications that must run on computers that do not have Microsoft Office Access 2003 installed, or are running older versions of Access. For those developers, Access 2003 Runtime is a necessity. The Access 2003 Runtime license comes with the Microsoft Office Access 2003 Developer Extensions, which is a component of Microsoft Visual Studio Tools for the Microsoft Office System. A developer who owns Visual Studio Tools for Office can bundle his application (MDB files and any other support files) with Access 2003 Runtime and distribute it to as many users as necessary. The physical runtime files are included with Microsoft Office 2003 Professional Edition or Microsoft Office Access 2003.
http://msdn.microsoft.com/en-us/library/aa167800(office.11,printer).aspx
01/11/2010
Page 2 of 8
Access Help Designers (including Filter by Form) VBA editor Figure 1 shows two instances of the same minimal MDB application. The instance on the left is running using Access Runtime, and the instance on the right is running in full Access. Not only is the difference stark, but the Access Runtime instance does provide a direct UI for opening objects as the intent is for developers to create the UI for this purpose.
Figure 1. An Access Runtime instance of a sample application compared to a full Access instance of the same application The developer of an application destined for an Access Runtime environment must create the application in such a way that the "missing" features of Access in the Access Runtime version are not obvious to the user. This document focuses on the steps the developer should take to create an Access application that runs just as effectively in an Access 2003 Runtime environment as it does with full Access installed.
Simulating the Access 2003 Runtime Environment from Full Access 2003
If you want to see how your application looks and works in an Access Runtime environment, you can use the /runtime command line switch with the full Access executable. Create a shortcut with a target like this: Copy Code
Note The line above has wrapped for printing. No line wrapping is supported in command line switches. Test your application under Access Runtime (either by using the command line switch or by installing with Access Runtime on a clean computer) before deploying the application to other users.
http://msdn.microsoft.com/en-us/library/aa167800(office.11,printer).aspx
01/11/2010
Page 3 of 8
Figure 2. Access 2003 provides the Switchboard Manager to create a startup form for your application quickly The limited menu provided by Access Runtime may be sufficient for simple applications, but most applications benefit from custom menus, toolbars, and shortcut menus. To create custom menus and toolbars, use the Customize dialog box (on the toolbar, choose Tools and then Customize) and select New on the Toolbars page of the dialog box. To create menu items or buttons, select and drag standard Access menu items onto your new menu or toolbar. You can also add menu items or buttons that call Access macros you created. By default, items created through the Customize dialog box are toolbars. You can change them to menus or shortcut menus by clicking the Properties button on the Toolbars page of the Customize dialog box. If you create toolbars, menus, or shortcut menus that are specific to a certain form, you can use the Form properties Menu Bar, Toolbar, and Shortcut Menu Bar to specify the items you created. You can specify default toolbars, menus, and shortcut menus for all forms in the application in the Startup options discussed in the next section. None of the standard Help for Access is available in Access Runtime. Often, a few well-written Help topics can head off a multitude of support calls and you can use a help authoring tool to create custom Help for your application. Once you have created the file, set the Help File property of each form to the name of your Help file. If your Help file includes topics for each form, you can also set the form's Help Context ID property so that the Help file opens directly to the most relevant page.
http://msdn.microsoft.com/en-us/library/aa167800(office.11,printer).aspx
01/11/2010
Page 4 of 8
Figure 3. The Startup dialog box provides a way to set defaults for your MDB file You can use the Startup dialog box to specify the following: A title for the application. This title appears in place of Microsoft Access as the title in the application's window. An icon for the application. The icon appears next to the window's title and in the Windows taskbar in place of the standard Access icon. A form that opens automatically when the database is opened. A default menu bar, toolbar, and shortcut menu for the application. You can override these settings for a particular form by changing the corresponding form properties. Whether or not the Status Bar should be displayed on startup. The following settings are ignored when the application runs Access Runtime and are relevant only when an application runs under full Access: Whether or not the Database window should be displayed on startup. Whether or not the default menus and toolbars should be allowed. Whether or not the user can make changes. Whether or not special keys are enabled in Access. In full Access, these special keys provide shortcuts to display certain windows and cause executing code to pause. Once Startup properties are set, the application from Figure looks like Figure 4 at startup in Access Runtime.
http://msdn.microsoft.com/en-us/library/aa167800(office.11,printer).aspx
01/11/2010
Page 5 of 8
Figure 4. The application now provides its own user interface when running in Access Runtime
Figure 5. Access uses a default dialog box for unhandled VBA errors From this message box, you can choose to debug the code in the Microsoft Visual Basic Editor, or you can stop the code's execution and return to interactive Access. The default error message for the same error under Access Runtime, shown in Figure 6, is quite different. Your only option is to click OK and subsequently exit the application entirely.
http://msdn.microsoft.com/en-us/library/aa167800(office.11,printer).aspx
01/11/2010
Page 6 of 8
Figure 6. Access Runtime uses a different default dialog box for unhandled errors Obviously, this is not the user interface you want to distribute to your users. It is always good programming practice to handle errors that may occur in VBA code, but when users work with the application in an Access Runtime environment, such error handling becomes crucial. Every procedure in an application should have, at a minimum, a basic
On Error GoTo
label error handler. Access macros provide no structure for handling errors. Macros are useful for creating custom menu items and defining shortcut keys, but because they lack error handling, use them only sparingly in any application.
Streamlining the Distribution Process with the Access 2003 Developer Extensions Tools
In addition to the Access 2003 Runtime license, the Access 2003 Developer Extensions include two wizards to streamline the process of packing and distributing Access applications. These wizards are the Custom Startup Wizard and the Package Wizard.
http://msdn.microsoft.com/en-us/library/aa167800(office.11,printer).aspx
01/11/2010
Page 7 of 8
remove the restrictions again when changes to the application are required. The Custom Startup Wizard, new in the Access 2003 Developer Extensions, simplifies the process of converting the development version of an application to an end-user version. The wizard asks questions about what the final version should look like and uses the answers to create a database with the appropriate settings. In addition, you can save all the choices made to a template. When you make changes to the original application and require a new deployed version, you can create it by using the wizard's command line interface and specifying the template as a command line argument. Among the changes the wizard can make are these: Make the final version an MDE. Prevent the Properties dialog box from appearing in Form view. Copy a selected macro to the Autokeys macro, providing shortcut keys for the end user that the developer does not want in his own version. Set startup options that differ from the original database. Disallow the Bypass (SHIFT) key so that users cannot avoid the startup options by holding down the SHIFT key while opening the database file. Digitally sign the database. Check the database for problems such as code that is not compatible with Access 2002, expressions that are blocked in Sandbox mode and missing references.
Conclusion
If you are creating an application that runs in an Access Runtime environment, you must carefully consider how to provide an interface for the user. You must also consider the fact that some users may own the correct version of Access and run the application in a full Access environment. Take care to test your application under both environments to make sure it properly balances usability in the Access Runtime environment with code security in a full Access environment. Once you created and tested your application, you can use the wizards in the Access 2003 Developer Extensions to create a final version that you can deploy to end users. It is a good idea to save the settings of both wizards as templates. You can then create a batch file that calls the command line
http://msdn.microsoft.com/en-us/library/aa167800(office.11,printer).aspx
01/11/2010
Page 8 of 8
interface of each wizard, sending the names of the respective template files. The next time you change the application and must create a deployment package, the process is as simple as running a single batch file.
http://msdn.microsoft.com/en-us/library/aa167800(office.11,printer).aspx
01/11/2010