ADT2: How to Modify Reattach NWIND Module in SOLUTION.MDBLast reviewed: June 2, 1997Article ID: Q125434 |
The information in this article applies to:
SUMMARYAdvanced: Requires expert coding, interoperability, and multiuser skills. The Reattach NWIND module in the Solutions sample application (SOLUTION.MDB) demonstrates a method of updating the connection information for attached tables in an application that uses multiple databases. This method assumes that a wizard utility database (WZLIB.MDA) is specified in the [Libraries] section of the MSACC20.INI file and that the MSAU200.DLL file is installed in the Microsoft Access directory. If these files are not loaded (such as when you are running a run-time version of Microsoft Access), then the method in the Solutions sample application does not work. This article describes how you can modify the method in the Reattach NWIND module to work in a run-time environment. NOTE: In Microsoft Access for Windows 95, the RefreshTableLinks module of the Solutions.mdb is completely self-contained. It does not rely on any references to a wizard library. This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Access Basic, please refer to the "Building Applications" manual.
MORE INFORMATIONTo modify the method in the Reattach NWIND module to work in a run-time environment, follow these steps while running the retail version of Microsoft Access. Each of these steps is described in detail later in this article.
Step 1: Import the Sample Code from SOLUTION.MDB
Step 2: Add a User-Defined Type from the WZLIB.MDA FileAdd the following Type statement to the Declarations section of the Reattach NWIND module you imported in the step above:
Type GetFileNameInfo hwndOwner As Integer szFilter As String * 255 szCustomFilter As String * 255 nFilterIndex As Long szFile As String * 255 szFileTitle As String * 255 szInitialDir As String * 255 szTitle As String * 255 Flags As Long nFileOffset As Integer nFileExtension As Integer szDefExt As String * 255 End TypeNote that this Type statement was copied from the wizard utility database (WZLIB.MDA) and renamed to avoid conflicts.
Step 3: Add Declare Functions from the WZLIB.MDA FileNOTE: In the following sample code, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in Access Basic.
Step 4: Modify the Sample GetMDBName() FunctionFollow these steps to modify the GetMDBName() function to use the new type you defined above, make the Find Database dialog box modal, and use the database name you specify:
Step 5: Modify the Sample GetMDBName2() FunctionNOTE: In the following sample code, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in Access Basic. Follow these steps to modify the GetMDBName2() function to use the new type you defined above:
Step 6: Modify the Sample AreTablesAttached() FunctionFollow these steps to modify the AreTablesAttached() function to look for a table in your attached database and replace references to NWIND.MDB and SOLUTION.MDB with references to your application:
Step 7: Add MSAU200.DLL to Application's Setup Using the Setup WizardWhen you create your application's Setup disks with the Setup Wizard, follow these steps to add the MSAU200.DLL file to the list of files to be included with your application:
Step 8: Call AreTablesAttached() Function in Application's AutoExec MacroIn the Solutions sample application, the Autoexec macro calls the AreTablesAttached() function. This function determines whether the table attachments are valid. If the attachments are not valid, the function prompts the user for the location of the attached tables. If the function returns True, the tables were successfully reattached. If the function returns False, the tables could not be found in the user-specified path and the database is closed. The AutoExec macro from the SOLUTION.MDB database is listed below:
Condition Action ------------------------------------ NOT AreTablesAttached() DoMenuItem OpenForm Action Arguments -------------------------- DoMenuItem Menu Bar: Database Menu Name: File Command: Close Database OpenForm Form Name: Startup REFERENCESMicrosoft Access Developer's Toolkit "Advanced Topics," version 2.0, Chapter 2, "Creating a Custom Setup Program," pages 19-35 Microsoft Access "Building Applications," version 2.0, Chapter 1, "Applications Basics," pages 17-19
|
Additional query words: attach adt reattach Nwind
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |