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
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