> Easiest is to go into the Relationship window & just delete the
relationship.
The scenario I'm working with is when users import multiple tables from
another database that contain relationships between each other, and those
relation names are potentially the same as existing relations - in which
case the relations are not visible in the Relationship window (users don't
have access to the Relationship window anyway). The reason I need to drop
the relations between the imported tables is so I can manipulate those
tables (drop columns, etc.) and massage the data so it can be inserted
elsewhere.
If you create relationships using DDL use a more human
readable name.
Access decides what names to give these relationships (and I never know how
many exist until runtime).
The syntax is correct. Make sure you are using the correct table. Make
sure that GUID is the actual name of the relationship. You might try
removing the square brackets and leave the curly braces. Or, remove
both the curly braces & the square brackets.
I tried that and a number of other things - no luck. When it comes to
working with Relations, I think DAO is the way to go.
Here's what I got working:
If db.Relations.Co unt > RELCOUNT Then
'RELCOUNT is a constant that is the number of
'known relations in the production database
db.Execute "DELETE * FROM tblImexRelation s;"
Set rstRel = db.OpenRecordse t("tblImexRelat ions")
For Each rel In db.Relations
rstRel.AddNew
rstRel!RelName = rel.Name
rstRel.Update
Next
Set rstImexRel = db.OpenRecordse t("qryImexRelat ions")
'qryImexRelatio ns retrieves all Relation names in
'tblImexRelatio ns that are not known Relations in the
'production database
Do While db.Relations.Co unt <> RELCOUNT
i = i + 1
rstImexRel.Move First
Do While Not rstImexRel.EOF
strRel = rstImexRel!RelN ame
db.Relations.De lete strRel
db.Relations.Re fresh
rstImexRel.Move Next
Loop
If i = 10 Then Exit Do
Loop
I've noticed it can take a few swipes before the relation is deleted. But
if it's not gone in 10 tries, something's wrong.