Display Relationship Name so I can drop it

A

Alan Rose

Hi I need to find the name of a relationship between two fields in different
tables in access, so I can drop the relationship (constraint). How do i find
out the name of a relationship? Access seems to only display the link in a
relationship diagram, it gives me no name. I have to use SQL to drop the
relationship I cant use access because it nopt available at remote site. Can
you display the relationship table for instance. Thanks.
 
J

John W. Vinson/MVP

Hi I need to find the name of a relationship between two fields in different
tables in access, so I can drop the relationship (constraint). How do i find
out the name of a relationship? Access seems to only display the link in a
relationship diagram, it gives me no name. I have to use SQL to drop the
relationship I cant use access because it nopt available at remote site. Can
you display the relationship table for instance. Thanks.

Should be able to adapt this:

Sub ShowAllRelations()
Dim db As DAO.Database
Dim rel As Relation
Dim fld As Field
Set db = CurrentDb
For Each rel In db.Relations
Debug.Print "Relation "; rel.Name, rel.Table, rel.ForeignTable,
Hex(rel.Attributes)
For Each fld In rel.Fields
Debug.Print fld.Name; " linked to "; fld.ForeignName
Next fld
Next rel
End Sub

Obviously you can pass the table and foreigntable names as
parameters...
 
C

Chris O'C via AccessMonster.com

How many times are you going to post the same question? Your question's
already been answered elsewhere and now John spent time answering it again
when he could have spent time helping someone who hasn't even been helped yet.


Crosspost one question in a few groups, don't post your question once for
every group you find. It wastes your time and others' time.

Chris
Microsoft MVP
 
A

Alan Rose

Many thanks John

John W. Vinson/MVP said:
Should be able to adapt this:

Sub ShowAllRelations()
Dim db As DAO.Database
Dim rel As Relation
Dim fld As Field
Set db = CurrentDb
For Each rel In db.Relations
Debug.Print "Relation "; rel.Name, rel.Table, rel.ForeignTable,
Hex(rel.Attributes)
For Each fld In rel.Fields
Debug.Print fld.Name; " linked to "; fld.ForeignName
Next fld
Next rel
End Sub

Obviously you can pass the table and foreigntable names as
parameters...
 
A

Alan Rose

Sorry. New to these groups and had no idea what one i should be in. Wont
happen again. cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top