Get relation among tables

  • Thread starter Thread starter Maileen
  • Start date Start date
M

Maileen

Hi,

i'm able for now to get information about a table like the following ones :

- name of the field
- format and type of field
- field description


but how can i detect that a relation is done between this table and
another one ?
and how can i get all information about this relation (name, type, which
fields, which other table,...)

thx,
Maileen
 
Hi Maileen!

Enter Menue <Tool / Relations> to see all relations between tables in your
db. If not all tables are shown right-click somewhere in the relation window
and select <View All>.

I also know that there are one function in Access where you can print a lot
of data about your db, including fieldnames etc. but I just can´t remember
where to find it right now, sorry!

I don´t know if this is what you where after or if you needed to get the
relations from VBA!? If so I´m not the guy to help you out. Not yet anyway!

// Niklas
 
yes i need to get it through VBA :(
thx anyway
M.
Hi Maileen!

Enter Menue <Tool / Relations> to see all relations between tables in your
db. If not all tables are shown right-click somewhere in the relation window
and select <View All>.

I also know that there are one function in Access where you can print a lot
of data about your db, including fieldnames etc. but I just can´t remember
where to find it right now, sorry!

I don´t know if this is what you where after or if you needed to get the
relations from VBA!? If so I´m not the guy to help you out. Not yet anyway!

// Niklas
 
Something like the following will show you the relations:

Dim dbCurr As DAO.Database
Dim fldCurr As DAO.Field
Dim relCurr As DAO.Relation

Set dbCurr = CurrentDb()
For Each relCurr In dbCurr.Relations
With relCurr
Debug.Print "There is a relationship named " & .Name & _
"between " & .Table & _
" and " & .ForeignTable
Debug.Print "The fields involved are:"
For Each fldCurr In relCurr.Fields
Debug.Print .Table & "." & fldCurr.Name & _
" and " & .ForeignTable & "." & fldCurr.ForeignName
Next fldCurr
End With
Next relCurr

Each relation also has an Attribute property, which specifies
characteristics of the relationship, and can be a combination of these
constants:

dbRelationUnique - The relationship is one-to-one.
dbRelationDontEnforce - The relationship isn't enforced (no referential
integrity).
dbRelationInherited - The relationship exists in a non-current database that
contains the two linked tables.
dbRelationUpdateCascade - Updates will cascade.
dbRelationDeleteCascade - Deletions will cascade

Note that I'm using DAO here. If you're using Access 2000 or 2002, you'll
need to set a reference to the Microsoft DAO 3.6 Object Library for this
code to work.
 
Back
Top