Troubleshooting Addins

If you need to step through add-in code to determine what is causing a problem, you have two options. One is to place a Stop statement in the add-in code, which will stop the code at that point when it is executing, so you can step through the code from that point. To do this, you must first close any open database, then open the add-in library database and add the Stop statement, save and close the add-in, then open a database and run the add-in that has the Stop statement in its code. Later, you will need to remove the Stop statement from the add-in code in a similar fashion.

The other (and quicker) alternative is to set a reference to the library database, so you can open its code modules and place breakpoints, and even modify the code temporarily, to test various alternatives. To set a reference to an Access add-in library database, complete the following steps:

If you plan to set a reference to a library database so you can step through its code easily (as described next), give its Visual Basic project a meaningful name, so it will say "Extras" (or whatever) instead of "Projectl" in the References dialog. To name the VB project, open the Visual Basic window, select the project row (the top row) in the Project Explorer, and rename it in the Name property of the properties sheet, as shown in Figure 14.10.

FIGURE 14.10

Renaming an add-in's project.

FIGURE 14.10

1. Open a module in any Access database, and select Tools, References to open the References dialog, as shown in Figure 14.11.

FIGURE 14.11

The References dialog in Access 2007.

References Synchronizing Contacts

Available References:

0 Visual Basic For Applications 0 Microsoft Access 2007 (Beta) Object Library 0 OLE Automation

0 Microsoft Office 2G07 Access database engine Objec 0 Microsoft Outlook 12.0 Object Library 0 Microsoft Scripting Runtime

0 Microsoft Office 12,0 Object Library 0Microsoft Word 12,0 Object Library

□ IAS Helper COM Component 1.0 Type Library

□ IAS RADIUS Protocol 1,0 Type Library

□ Active Directory Types

□ Active Setup Control Library

□ ActiveMovie control type library

1 ActiveX HJI tn nerfnrm Minrntinn nf MS Rennsitnrv V' v i i jJ

Priority ±1

-WDScnrLK 1.0 Type Library--

Location : C : ^Program Files\Common Files\5ymantec 5hared\WD5cnrLK, c Language: Standard

2. Click the Browse button to browse for the add-in library database, and select Add-ins (*.mda) in the Files of Type drop-down list, if you are setting a reference to an Access 2003 or earlier (.mda) library database, or All Files (*.*) to set a reference to an Access 2007 (.accda) library database (see Figure 14.12).

FIGURE 14.12

Setting a reference to an Access 2002-2003 library database.

Look in: Addlns

¡¡Hoe* ° n-

^"Design Schemes, mda -J Extras.mda LNC Rename, mda

Filename: Extras, mda

1 Jf ¡n ]

Files of type: Add-ins f.mda)

v i i

1 Mah |

3. Click Open to set the reference; the project name of the add-in now appears checked in the References dialog, as shown in Figure 14.13.

FIGURE 14.13

A reference to an add-in library database.

FIGURE 14.13

A reference to an add-in library database.

4. Now you can see the add-in project in the Project Explorer, and open its module(s) and work with them much like modules in the current database, as shown in Figure 14.14.

FIGURE 14.14

Opening an add-in module in the Visual Basic window of a database.

FIGURE 14.14

Opening an add-in module in the Visual Basic window of a database.

' Though you can edit code in a library database after setting a reference to it, and run ~ the code to test whether the modifications fix a problem, the changes aren't saved to the library database, so save any modified code to a text file, which you can then copy and paste into the library database when you next open it directly.

0 0

Post a comment