I'm trying to use VB to re-create table relationships based on an MDB
that is "perfect". The approach I took is to destroy all relationships
and then recreate from scratch, but I seem to be running into residual
data. I am using DAO (I know, but I have my reasons). The question is,
whay do I need to append a random number to the relationship name to
avoid 3284 ("Index already exists") errors? The target database is
normally identical to the baseline, but this routine is a "safety
check". The code below works, but I am uncomfortable with the Int(Rnd(1)
feature. Has anyone run into this?

Private Sub CreateNewRelationships(SourceMDB As DAO.Database,
DestinationMDB As DAO.Database)

Dim rel As DAO.Relation '* SourceMDB
Dim newrel As DAO.Relation '* DestinationMDB
Dim relfld As DAO.Field '* SourceMDB
Dim fldPointer As Long
Dim newrelName As String '* create new unique

On Error GoTo ErrHandler

DeleteAllRelationsInMDB DestinationMDB '* remove ALL

'* create from scratch using SourceMDB as model
For Each rel In SourceMDB.Relations
'newrelName = rel.Name
newrelName = rel.Name & Int(Rnd(1) * 100) '* some hidden prob
requires a new unique Name
Set newrel = DestinationMDB.CreateRelation(newrelName, rel.Table,
rel.ForeignTable, rel.Attributes)
With newrel
fldPointer = 0
For Each relfld In rel.Fields
.Fields.Append .CreateField(relfld.Name)
.Fields(fldPointer).ForeignName = relfld.ForeignName
fldPointer = fldPointer + 1
End With
DestinationMDB.Relations.Append newrel
Set newrel = Nothing

Exit Sub
Err.Source = Err.Source & vbCrLf
& "modv26Conversion.CreateNewRelationships"
Err.Raise Err.Number, Err.Source, Err.Description
End Sub