Microsoft KB Archive/304007

From BetaArchive Wiki

Article ID: 304007

Article Last Modified on 5/7/2004



APPLIES TO

  • Microsoft Office XP Developer Edition



This article was previously published under Q304007

For a Microsoft Office 97 Developer Edition version of this article, see 180284.

For a Microsoft Office 2000 Developer version of this article, see 247530.

SUMMARY

This article lists available resources and troubleshooting steps that you can use to avoid common mistakes when you create a custom application.

Note How to create a distributed run-time application is explained step-by-step in the "Microsoft Office XP Developer's Guide." A soft copy of this guide is available in the online documentation. To view this topic online, follow these steps:

  1. Click Start, point to Programs, point to Microsoft Office XP Developer, and then click Microsoft Office XP Developer Online Documentation.
  2. Under Contents, expand Developing Office Developer Applications, and then expand Deploying Your Application.
  3. Click the topic Creating a Setup Package using the Packaging Wizard.

Things to consider when you create and distribute a run-time application

When you create and distribute the run-time application, consider the following questions:

  • How was the application created?
  • Was the application tested and debugged?
  • Were Help Files and Topic Files Created?
  • Was the application tested in the run-time environment?
  • Were Images Created by Using the Packaging Wizard?
  • Was the application packaged and distributed?

The following sections contain more information about these questions.

How was the application created?

Before you can consider the application finished, answer the following questions:

  • Did you develop a plan?
  • Did you build the application around forms?
  • Did you include error handling?
  • Did you create custom menu bars and toolbars?
  • Did you add startup options?
  • If security is required, did you properly secure the application?

Did you develop a plan?

The first step in the process is to develop a design for the application. Make sure you have answered to the following questions:

  • Was the application secured? If so, how?
  • Was the database split? If so, how?
  • Will the application be run from a network? If so, how?
  • What is the best way to update the application after it is distributed?

Did you build the application around forms?

In general, it's a good idea to build your application around forms. Users should interact with the application through the forms that you create instead of through the underlying queries or tables. By building your application around forms, you can control the following:

  • The commands that are available to users.
  • The flow of the application.
  • The appearance and behavior of the application.
  • The way that users access data.
  • The way that data is displayed.

Note For more information about using forms in the application, see Chapter 2, page 87 of the "Microsoft Office XP Developer's Guide". A soft copy of this guide is available in the online documentation. To view this topic online, follow these steps:

  1. Click Start, point to Programs, point to Microsoft Office XP Developer, and then click Microsoft Office XP Developer Online Documentation.
  2. At the bottom of the window, click the Search tab.
  3. On the Search tab, type working with forms, and then click the Search button.
  4. In the Search Results list, double-click the topic Working with Reports, Forms, and Data Access Pages.

For additional information about form features that you cannot include in your custom application, click the following article number to view the article in the Microsoft Knowledge Base:

306361 Filter-by-form is not available in run-time applications


Did you include error handling?

It's important to include error-handling code in the application's Visual Basic for Applications procedures. When Microsoft Access encounters Visual Basic run-time errors that are not handled, it closes the application without displaying any error messages.

Microsoft Access also closes the application without displaying any error messages if it encounters any run-time errors in the application's macros. However, you cannot trap errors in macros. If you want to ensure that your application traps run-time errors, use Visual Basic procedures instead of macros.

Note Avoid using the End statement in the run-time application. The End statement closes the application without producing a trappable run-time error.

Note For more information about implementing error handling and handling run-time errors in the application, view the following topic online by performing the following steps:

  1. Click Start, point to Programs, point to Microsoft Office XP Developer, and then click Microsoft Office XP Developer Online Documentation.
  2. Expand the topic Microsoft Office XP Developer.
  3. Expand the topic Developing Office Developer Applications.
  4. Click to view the topic Debugging and Error Handling.

Did you create custom menu bars and toolbars?

To prevent users from making changes to the application, the run-time environment removes several menus and commands from the menu bar. For example, the View, Tools, and Format menus are removed from all windows. Commands on the Edit, Insert, and Records menus are also removed from the menu bars in Datasheet view of tables and queries, in Form view, and in print preview.

You must control the menus and commands that are available to users of the application by building the application around forms that have custom menus. The run-time environment disables all built-in Microsoft Access toolbars. However, even though the run-time environment does not support built-in toolbars, you can add your own custom toolbars to the application. When you create a custom toolbar, it is stored in the current database. It is automatically available to the application.

For additional information about creating custom menu bars and toolbars, click the following article number to view the article in the Microsoft Knowledge Base:

306369 How to create command bars by using Visual Basic code


Did you add startup options?

You can set the following startup options for the custom application:

  • Application title
  • Application icon
  • Name of custom menu bar
  • Name of startup form

If security is required, did you properly secure the application?

When you distribute the run-time application to users who have Microsoft Access on their computers, you should take several precautions to protect the database. To prevent users from making modifications to the objects and code, or from inadvertently causing problems with the application, consider these recommendations:

  • Specify the /runtime option on all command lines that you use to start the application.
  • Use the Security Wizard that is provided with Microsoft Access to secure all the objects in the database.
  • Use customized menus and toolbars in the application.
  • Set the AllowBypassKey property to False to disable the SHIFT key.
  • Set any database startup properties that could potentially give users access to the Database window or any Design view.
  • If the database contains Visual Basic code, distribute it as an MDE file.

Note For more information about implementing security in the application, view the following topic online by performing the following steps:

  1. Click Start, point to Programs, point to Microsoft Office XP Developer, and then click Microsoft Office XP Developer Online Documentation.
  2. Expand the topic Microsoft Office XP Developer.
  3. Expand the topic Developing Office Developer Applications.
  4. Expand the topic Deploying Your Application.
  5. Expand the topic Deploying Microsoft Access Applications using the Access Runtime.
  6. Click the topic Developing Access Runtime Applications
  7. On the Developing Access Runtime Applications page, click to view the section Security for Your Application.

Was the application tested and debugged?

When you program an application, you must consider what happens when an error occurs. An error can occur in an application for two reasons. The first reason is that some condition at the time the application is run causes the otherwise valid code to fail. For example, if the code attempts to open a table that the user has deleted, an error occurs. The second reason is that the code may contain improper logic that prevents it from doing what you intended. For example, an error occurs if the code attempts to divide a value by zero.

If you have not implemented error handling, Visual Basic halts execution and displays an error message when an error occurs in the code. The user of the application is likely to be confused and frustrated when this happens. You can prevent many problems by including thorough error-handling routines in the code to handle any errors that may occur.

When you add error handling to a procedure, you should consider how the procedure routes execution when an error occurs. The first step is to enable an error handler by including some form of the On Error statement in the procedure. The On Error statement directs execution in the event of an error. If there is no On Error statement, Visual Basic simply halts execution and displays an error message when an error occurs.

When an error occurs in a procedure that contains an enabled error handler, Visual Basic does not display the normal error message. Instead, it routes execution to an error handler if one exists. When execution passes to an enabled error handler, that error handler becomes active. Within the active error handler, you can determine the type of error that has occurred and address it in a manner of your choosing. Microsoft Access provides two objects that contain information about errors that have occurred: the Visual Basic Err object and the DAO Error object. Another object that contains information about errors is the ADO Error object.

Were help files and topic files created?

Your application should use its own Help file rather than the full Microsoft Access Help file (Acmain10.chm). If you want to provide Help for your run-time application, you must create your own Help file, and then set the AppHelpFile registry key. You can also provide topic IDs for your Help file so that you can create context-sensitive help for your topics. Microsoft Office XP Developer Edition includes a Help Workshop to assist you in creating custom Help files.

For additional information creating your own Help files, click the following article number to view the article in the Microsoft Knowledge Base:

306370 How to display context-sensitive help for the What's This button


Was the application tested in the run-time environment?

You should always test your application on a clean computer. This will ensure that when you package your application you are including all the files that you need to successfully run your application. To test your application on a clean computer, follow these steps:

  1. On a clean computer (a computer that has a newly installed version of Windows, and no other applications or components that you are including with your custom application), run your Setup program.
  2. Completely test your application.

Were images created by using the Packaging Wizard?

When your custom application is finished and ready to be distributed to users, you need a way for users to install it. Microsoft Office XP Developer includes the Packaging Wizard. This wizard helps you create a custom Setup program for your application.

When you run the Packaging Wizard, you answer questions about the files that you want to copy to users' hard disks, the Microsoft Access features that your application requires, and how the Setup program should customize the installation of your application. Then, the Packaging Wizard compresses your application files and groups them so you can copy them to a CD or to a network drive. If your users do not already have Microsoft Access installed on their computers, the Packaging Wizard can create an installation that includes the run-time version of Microsoft Access.

The Packaging Wizard compresses and groups files based on your choices and creates a custom template that the Setup program will use to install your application.

Was the application packaged and distributed?

After your Setup program is finished, you are ready to distribute your application. To install your application, users can simply run the Setup program file included on your CD or in your network installation folder.

For additional information about installing your custom application, click the following article numbers to view the articles in the Microsoft Knowledge Base:

313166 How to obtain and install Office XP Developer Service Pack 1 (S about installing your custom application)


291402 Building an Access run-time package can be very slow


295287 Replication Manager setting is not saved in the Packaging Wizard script


296231 How to create context-sensitive HTML Help files


Note If you want to modify your custom Setup program after running the Packaging Wizard, or if you need to update files included in your application, run the Packaging Wizard again. On the first page, choose the Setup script name that you saved in a previous Packaging Wizard session.


Additional query words: Package and Deployment Wizard pdw p&d

Keywords: kbinfo KB304007