PRB: Error Message If Path Info for Attached Databases Changes

PSS ID Number: Q100969
Article last modified on 10-12-1993

1.00 1.10
WINDOWS

---------------------------------------------------------------------
The information in this article applies to:

 - Microsoft Access versions 1.0 and 1.1
---------------------------------------------------------------------

SYMPTOMS
========
The following error message is displayed:
   Couldn't find table <table name>

CAUSE
=====
The Access Distribution Kit (ADK) recommends splitting up databases.
You can place your forms, reports, and macros in an objects file, such
as PROGRAM.MDB, and place your tables in a data file called DATA.MDB.
When you create a database that has attached tables, the specific path to
these attached tables is stored in the database. If the path to these
attached tables has changed, you receive the above error message.
Splitting the database simplifies updating, since you can redistribute
the objects file and copy over the PROGRAM.MDB file without destroying
your data.

RESOLUTION
==========
The ADK requires that your database have an AUTOEXEC macro. From
within the AUTOEXEC macro, call an Access Basic function to verify
that the attached tables are actually attached. If they are not
attached, you must attach them.
When you start your application, make sure that the program's working
directory property is the same directory as the .MDB file. The
Microsoft Access Setup Wizard automatically sets this property
automatically in Program Manager. Use the CurDir() function to
determine from what directory the program is being executed, then
attach the files to that directory.

MORE INFORMATION
================
1. Create a new directory (for example, C:\ATTACH).
2. Copy the sample database NWIND.MDB from your ACCESS directory to
   the C:\ATTACH directory.
3. Start MSACCESS.EXE. From the File menu, choose New. Create a new
   database called PROGRAM.MDB in the C:\ATTACH directory.
4. From the Database window, choose Module and then choose New. Enter
   the following function:
      Function Reattach ()
         On Error GoTo attach_files
         DoCmd SelectObject a_table, "Employees", True
         Exit Function
      attach_files:
      'NOTE: In the following sample code, an underscore (_) is
      'used as a line continuation character. Remove the underscore
      'when re-creating this code in Access Basic.
         DoCmd TransferDatabase A_ATTACH, "Microsoft Access", _
                 CurDir &"\nwind.mdb", A_TABLE, "Employees", _
                  "Employees"
         Exit Function
      End Function
5. Save the module as Module1.
6. Create the following new macro and save it as AUTOEXEC:
      Macro Name     Action     Argument
      ----------------------------------
      Autoexec       RunCode    Reattach()
7. Close PROGRAM.MDB, then reopen it. Note that PROGRAM.MDB attaches
   the Employees table from NWIND.MDB.

Additional reference words: 1.0 1.10 attach ADK datafile
KBCategory:
KBSubcategory: IeaAccmdb GnrlNw
Copyright Microsoft Corporation 1993.