RE:   "Tame Database Attachments with Attachment Manager" 
      by Paul Litwin 
      from the November 93 issue of Smart Access

Compatibility: Works with version 1.0 and 1.1 of Access 

This archive contains:
 ATTMNG.MDB    The database.
 AM_DOC.TXT  (this file)

This sample database accompanies the above article.  

How to Install It
ATTMNG.MDB is an Access database that contains the attachment manager application. You can 
try it out by creating attachments directly in ATTMNG, or you can import the application 
into your own database. To use Attachment Manager in your database, simply import the 
macro _zsmcrImportAttachManager using the File-Import... command. Then run this macro to 
import the zstblAttachments table, along with several queries, forms, macros and modules.  

The objects are:

Object 
Type      Object                     Purpose
Tables    zstblAttachments           Contains names of attached tables, 
                                     path to source database, and status.
Queries   zsqryBadAttachments        A select query that returns only broken 
                                     attachement records.  Source for 
                                     zsfsubBadAttachments.
          zsqupdAttachPath           An update query used to make global path 
                                     changes in zstblAttachments.
Forms     fmsgHelp                   The help message that loads via the 
                                     Auotexec macro. (This form is not copied 
                                     to your database by the import macro.)
          zsfrmGlobalChange          A modal form used in developer mode to 
                                     change the path of all attachments.
          zsfrmManualAttach          A form used by both users & developers to 
                                     manage attachments.  In developer mode, 
                                     this form has extra functionality. 
          zsfsubAttachments          A subform used by zsfrmManualAttach in 
                                     developer mode.
          zsfsubBadAttachments       A subform used by zsfrmManualAttach in 
                                     user mode.
Macros    _zsmcrImportAttachManager  Import this macro to your database and
                                     run it to import the remaining objects.
          AutoExec                   The autoexec macro for the ATTMNG database.
                                     (This macro is not copied 
                                     to your database by the import macro.)
          AutoexecATTMNG             A sample Autoexec macro which calls 
                                     zsmcrCheckAttachments.  You may wish 
                                     to rename to Autoexec after it is imported.
          mfmsgHelp                  The macro for the help message form.
                                     (This macro is not copied 
                                     to your database by the import macro.)
          zsmcrCheckAttachments      Calls the CheckAttachments function to check 
                                     all attached tables.
          zsmcrManageAttachments     Calls the ManageAttachments function to bring up
                                     zsfrmManualAttach in developer mode.
Modules   basAutoAttach              Contains CheckAttachments() and supporting 
                                     functions. Used to automatically check 
                                     attachments.
          basFileOpen                Contains functions that call the Windows API 
                                     common dialogs.
          basManageAttachments       Contains ManageAttachments() which is used to 
                                     open zsfrmManualAttach in developer mode.
          bzsfrmGlobalChange         Contains functions that respond to events on 
                                     zsfrmGlobalChange form.
          bzsfrmManualAttach         Contains functions that respond to events on 
                                     zsfrmManualAttach form.

To integrate Attachment Manager into your database, follow these three steps:

1. When you wish to attach to an external table, open the zsfrmManualAttach form (or run 
the zsmcrManageAttachments macro) and add a new record with the local table name, the 
remote table name (it defaults to the same name as the local table) and the full path 
to the source database. You can enter the path directly or browse for it using the 
standard Windows File Open dialog box. Attachment Manager doesn't care if the 
attachments already exist, because once you exit the form using the OK button, all 
attachment records will be verified. If they already exist, nothing will happen. 
Otherwise, Attachment Manager will create the attachments for you. If Attachment 
Manager can't attach to a table, you will be notified of the "bad" attachments and 
given a chance to fix them.

2. Use the sample Autoexec macro, or call the function CheckAttachments() from your 
Autoexec macro.  If you call the function directly, pass it the parameter "Auto". Now, 
every time the database is opened, any and all attachments (as specified in step 1) 
will be checked.

3. When you wish to move the attached databases, or install the application on a 
different system, you can pre-specify the new paths using zsfrmManualAttach before 
making the move. If you've changed the path to one that is no longer valid on your 
system, you can skip the validation step using the form's Cancel button (your changes 
are preserved).  After moving the database, Attachment Manager's automated mode will 
verify the new paths and automatically reattach the tables using the new paths.  If 
any errors are encountered, the user will be notified and will be given the 
opportunity to go into manual repair mode.  The process is simple enough that you 
could "walk" your users through it over the telephone.

How it works
See the article.

-Paul Litwin

