Results 1 to 5 of 5
  1. #1
    securitywyrm is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    97

    List tables that have no relationships?

    Is there a way to generate a list of tables in Access that do not have any relationships in the relationships manager? The data I'm working with is a colossal spiderweb and i want to be sure none of them slipped through the cracks.

    Or as another option, is there a way to export the table relationships? I could compare that against a list of tables to see if I missed any.

  2. #2
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    If you don't notice they are not linked then do they need to be linked? put some test data in and run through some"normal use" see if you encounter any problems.

  3. #3
    securitywyrm is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    97
    Quote Originally Posted by Homegrownandy View Post
    If you don't notice they are not linked then do they need to be linked? put some test data in and run through some"normal use" see if you encounter any problems.
    All the tables I'm importing need to be linked, but unfortunately I can't rely on my eyes to ensure this (visually impaired). Plus the ability to export or view which tables do and don't have relationships in Access will be very useful in upcoming projects.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Here is some code that will identify the relations and the tables involved in the current database. It does not show system tables or relations. It should give you a good starting point.
    Code:
    ' ----------------------------------------------------------------
    ' Procedure Name: RelationX
    ' Purpose: Routine to print relations in currentdb
    ' that do not involve system tables.
    ' List relation name from Access, and
    ' the table and foreigntable names and
    ' the fields in table and foreigntable
    ' to the immediate window.
    '
    ' Procedure Kind: Sub
    ' Procedure Access: Public
    ' Author: Jack
    ' Date: 10-Mar-20
    ' ----------------------------------------------------------------
    Sub RelationX() 'show relations for non system tables in currentdb
    10        On Error GoTo RelationX_Error
              Dim dbs As DAO.Database
              Dim rel As DAO.relation
              Dim prpLoop As Property
              Dim fldLoop As Field
              Dim RCount As Long   'count each relation
    20        Set dbs = CurrentDb
    30        RCount = 1
              ' Print a report showing all the different parts of
              ' the relation and where each part is stored.
    40        For Each rel In dbs.Relations
    50        If Not rel.name Like "Msys*" Then   'only process non system tables/relationships
    60            Debug.Print RCount & "  Properties of <" & rel.name & "> Relation"
    70            Debug.Print "   Table = " & rel.table
    80            Debug.Print "   ForeignTable = " & rel.ForeignTable
    90            Debug.Print "    Fields of " & rel.name & " Relation"
    100           For Each fldLoop In rel.Fields
                      'Debug.Print " " & fldLoop.name
    110               Debug.Print "     Name = " & fldLoop.name
    120               Debug.Print "     ForeignName = " & fldLoop.ForeignName
    130           Next fldLoop
    140           Debug.Print
    150           End If
    160           RCount = RCount + 1
    170       Next rel
              
              
    180       On Error GoTo 0
    RelationX_Exit:
    190       Exit Sub
    
    RelationX_Error:
    200       MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure RelationX, line " & Erl & "."
    210       GoTo RelationX_Exit
    End Sub
    Here is a sample of the output:

    Code:
    1  Properties of <AnimalAnimalCapture> Relation
       Table = Animal
       ForeignTable = AnimalCapture
        Fields of AnimalAnimalCapture Relation
         Name = AnimalId
         ForeignName = AnimalId
    
    2  Properties of <AnimalAnimalLocs> Relation
       Table = Animal
       ForeignTable = AnimalLocs
        Fields of AnimalAnimalLocs Relation
         Name = AnimalId
         ForeignName = AnimalId
    Good luck with your project.

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    Also,see if the info in this article can be of use http://www.mendipdatasystems.co.uk/r...ps1/4594533224
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Tables and relationships
    By k11ngy in forum Database Design
    Replies: 10
    Last Post: 01-14-2019, 03:54 AM
  2. Replies: 13
    Last Post: 11-03-2013, 10:25 PM
  3. Replies: 1
    Last Post: 10-02-2012, 09:52 AM
  4. 8 Tables with Relationships
    By bigdogxv in forum Access
    Replies: 1
    Last Post: 12-09-2009, 09:37 PM
  5. Tables Vs Relationships
    By Bruzer in forum Database Design
    Replies: 8
    Last Post: 09-06-2009, 04:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums