Article ID: 164238
Article Last Modified on 2/12/2007
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 Function
To run this function, type the following line in the Debug window,
and then press ENTER.
CleanMeUp
Categories
Customers
Employees
Order Details
Orders
Products
Shippers
Suppliers
Categories
Customers
Employees
Order Details
Orders
Products
Shippers
Suppliers
Additional query words: VSS ACCSCC SCC source code duplicate multiple
Keywords: kbbug KB164238