Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Dec 2000
    Thanked 0 Times in 0 Posts

    VBA to check referential integrity?

    How would I check referential integrity using VBA?

    I have a massive number of tables and relationships in this database and need to check that referential integrity is turned on for each relationship.

    Checking this stuff manually in the relationship window would be a nightmare.

    Thanks in advance.

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Indianapolis, Indiana, USA
    Thanked 0 Times in 0 Posts

    Re: VBA to check referential integrity?

    Hi Stephan,

    Try this code:<pre>Function PrintRelationships()
    Dim dbs As DAO.Database
    Dim rln As DAO.Relation

    Set dbs = CurrentDb()
    For Each rln In dbs.Relations
    Debug.Print "Name: " & rln.Name & vbCrLf _
    & "Table: " & rln.Table & vbCrLf _
    & "Foreign Table: " & rln.ForeignTable & vbCrLf _
    & "Attributes: " & rln.Attributes & vbCrLf
    Next 'rln
    End Function</pre>

    You'll have to look in the object browser (DAO.RelationAttributeEnum) for the definitions of the Long codes. You can also consult the Access helpfile under Relationship Attributes.

    HTH <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts