ACC97: Duplicate Relationships Multiply in Back-End DatabaseLast reviewed: January 30, 1998Article ID: Q164238 |
The information in this article applies to:
SYMPTOMSAdvanced: Requires expert coding, interoperability, and multi-user skills. You notice duplicate relationships appearing in a data (back-end) database under one or both of the following conditions:
This article also assumes that you are familiar with using the client-side capabilities of Visual SourceSafe. For more information about Visual SourceSafe, please refer to the "Visual SourceSafe User's Guide" or the Help topics available from the Visual SourceSafe Help menu.
RESOLUTIONRun the following custom procedure periodically in your data database to remove the duplicate relationships that are created when you import linked tables, or when you check out, check in, or get the latest version of Data and Misc. Objects in a database under source code control. Create a module in your data database and type the following procedure:
Function CleanMeUp() Dim db As Database Dim relFirst As Relation, relSecond As Relation Dim bDifferent As Boolean Dim iField As Integer Set db = CurrentDb() For Each relFirst In db.Relations() For Each relSecond In db.Relations() ' Make sure the names are different, the foreign tables are ' the same, the tables are the same, and they both have the ' same number of fields. If (relFirst.Name <> relSecond.Name) And _ (relFirst.ForeignTable = relSecond.ForeignTable) And _ (relFirst.Table = relSecond.Table) And _ (relFirst.Fields.Count = relSecond.Fields.Count) Then bDifferent = False For iField = 0 To relFirst.Fields().Count - 1 ' If any of the fields are different, these two rels ' are not duplicates. If (relFirst.Fields(iField).Name <> _ relSecond.Fields(iField).Name) Or _ (relFirst.Fields(iField).ForeignName <> _ relSecond.Fields(iField).ForeignName) Then _ bDifferent = True Next iField ' If you don't find any differences, then delete the ' second rel. If Not bDifferent Then db.Relations.Delete relSecond.Name End If End If Next relSecond Next relFirst End FunctionTo run this function, type the following line in the Debug window, and then press ENTER.
CleanMeUpAfter the procedure runs, click Relationships on the Tools menu, or open the MSysRelationships system table in your data database and note that duplicate relationships are gone.
STATUSMicrosoft has confirmed this to be a problem in Microsoft Access 97. This problem no longer occurs in Microsoft Access 97 Service Release 1.
MORE INFORMATIONThe sections that follow contain steps to reproduce the problem in two different scenarios. To prepare for either example, follow the next 9 steps first. CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.
Steps to Reproduce Problem by Importing Linked Tables
Steps to Reproduce Problem in a Database Under Source Code ControlIn order to follow these steps, you must have both the Source Code Control component of Microsoft Office 97 Developer Edition Tools and source code control software, such as Microsoft Visual SourceSafe, installed on your computer.
|
Additional query words: VSS ACCSCC SCC source code duplicate multiple
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |