relationship

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a module that imports the tables and relationships from one db into
another. It works great, but I have noticed in the MSysRelationships table
of the replicated db that the field szRelationship changes eventhough it is
the same relationship. For example, the first time the module would run, the
field may say:
tbl_KeyPersonneltbl_KeyPersonnel_PlatformLeader28, then the next time it
will read tbl_KeyPersonneltbl_KeyPersonnel_PlatformLeader50. When it gets to
be too large for the field, an error occurs. The number seems to increase,
but I haven't found the reason. Any help would be great.

Code:

For Each relationship In dbExport.Relations
dbExport.Relations.Delete relationship.Name
Next

dbImport.Relations.Refresh
dbExport.Relations.Refresh
For Each relationship In dbImport.Relations

Set relnew = dbExport.CreateRelation(relationship.Name & Int(Rnd(1) *
100), relationship.Table, _
relationship.ForeignTable, relationship.Attributes)

x = 0
For Each relfield In relationship.Fields
relnew.Fields.Append relnew.CreateField(relfield.Name)
relnew.Fields(x).ForeignName = relfield.ForeignName


x = x + 1
Next
dbExport.Relations.Append relnew
Next
 
Does it matter?

FWIW, make sure Name AutoCorrect is turned off. It can do weird things when
tracking the names involved in the relationships.

Also, Stephen Lebans has an interesting utility for saving/restoring the
relationship views at www.lebans.com
 
Back
Top