This article was previously published under Q154397
This article has been archived. It is offered "as is" and will no longer be updated.
Advanced: Requires expert coding, interoperability, and multiuser skills.
The RefreshTableLinks module in the Developer Solutions sample application(Solutions.mdb) demonstrates a method of updating the connectioninformation for linked (attached) tables in an application that usesmultiple databases.
This article describes how you can modify the functions used in themodRefreshTableLinks module (or RefreshTableLinks module in Solutions.mdbfor Microsoft Access 7.0) to work in a run-time environment.
This article assumes that you are familiar with Visual Basic forApplications and with creating Microsoft Access applications using theprogramming tools provided with Microsoft Access. For more informationabout Visual Basic for Applications, please refer to your version of the"Building Applications with Microsoft Access" manual.
To modify the functions used in the modRefreshTableLinks module to work ina run-time environment, follow these steps while running the retail versionof Microsoft Access. Each of these steps is described in detail in thefollowing sections.
Import the modRefreshTableLinks (or RefreshTableLinks in Solutions.mdb for Microsoft Access 7.0) module from Solutions.mdb.
Modify the sample CheckLinks() function.
Modify the sample FindNorthwind() function.
Modify the sample RelinkTables() function.
Call the ReLinkTables() function in your application's AutoExec macro.
Import the modRefreshTableLinks Module from Solutions.mdb:
With your database open, on the File menu, point to Get External Data, and then click Import.
In the Look In box, select the Samples folder under your Microsoft Access folder.
In the File Name box, select Solutions.mdb, and then click Import.
In the Import Objects dialog box, click the Modules tab, select modRefreshTableLinks, and then click OK.
Follow these steps to modify the CheckLinks() function to test if thepath of your current attachments are correct:
Search the CheckLinks() function for the following line:
Replace "Products" with the name of a linked table in yourapplication.mdb:
Set RST=dbs.OpenRecordset("<your table name>")
Follow these steps to modify the FindNorthwind() function to display theOpen File dialog box for the user to locate your back-end database. Thefunction returns the full path to the back-end database:
Find the following line in the FindNorthwind() function:
msaof.strDialogTitle = "Where Is Northwind?"
Replace "Northwind" with the name of your back-end database:
msaof.strDialogTitle = "Where Is <your database name>?"
Follow these steps to modify the RelinkTables() function to look fora table in your linked database and replace references to Northwind.mdb andSolutions.mdb with references to your application:
Search the RelinkTables() function for one of the following lines:
Const conAppTitle = "Developer Solutions"
Const conAppTitle = "Solutions"
Replace "Developer Solutions" or "Solutions" with the name of your application database:
Const conAppTitle = "<your application database>"
Search for and replace all references to Northwind.mdb, Solutions.mdb, and "Developer Solutions or Solutions." Replace these references with your database names.
Call the ReLinkTables() Function from your SwitchBoard's Load event or inyour application's AutoExec Macro.
In the Developer Solutions sample application, the ReLinkTables() functionis called from the DeveloperSolutions (or Solutions in Microsoft Access7.0) form's Load event. This function determines whether the tableattachments are valid. If the attachments are not valid, the functionprompts the user for the location of the linked tables. The ReLinkTables()function could also be called from your AutoExec macro.The command you would add to the Switchboard's Load event is:
If CheckLinks = False Then RelinkTables
The AutoExec macro entries are as follows:
Condition Action ------------------------------------------- NOT CheckLinks() RunCode Action Arguments ----------------------------- RunCode Function Name: RelinkTables()