Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7893885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:14:56+00:00 2026-06-03T07:14:56+00:00

For source control I am trying to export the table relations from Access in

  • 0

For source control I am trying to export the table relations from Access in order to be able to re-import them. From what I can tell in order to do this I only need four pieces of information.

  1. Table Name
  2. Table Field Name
  3. Foreign Table Name
  4. Foreign Table Field Name

I got the first three down, but having an issue figuring out the last bit of information. Usually my tables and field names are always the same so it is generally not a problem but I would really like if this vbscript can account for times in the future where maybe perhaps it is not as evident. Here is a snippit of the code I am using:

Dim db, totalrelations, i, j

Set db = oApplication.CurrentDb
totalrelations = db.Relations.Count
WScript.Echo totalrelations
If totalrelations > 0 Then
    WScript.Echo "opening " & totalrelations
    For i = totalrelations - 1 To 0 Step -1
       'WScript.Echo (db.Relations(i).Name)
       'WScript.Echo (db.Relations.Item(i).name)

       WScript.Echo "Attributes: " &       db.Relations.Item(i).Attributes

 '**            'iterate through the count!!!
       WScript.Echo "Field count: " & db.Relations.Item(i).Fields.Count

       If db.Relations.Item(i).Fields.Count > 0 Then
            For j = 0 To db.Relations.Item(i).Fields.Count - 1
                WScript.Echo j & " Field name: " & db.Relations.Item(i).Fields.Item(j).Name
            Next 
       End If
       WScript.Echo "ForeignTable: " &     db.Relations.Item(i).ForeignTable
       WScript.Echo "Name: " &             db.Relations.Item(i).Name
       WScript.Echo "PartialReplica: " &   db.Relations.Item(i).PartialReplica

       WScript.Echo "propertycount: " & db.Relations.Item(i).Properties.Count
       'Simply repeats everything we already know
       If db.Relations.Item(i).Properties.Count > 0 Then
            For j = 0 To db.Relations.Item(i).Properties.Count -1
                WScript.echo j & " PropertyName:" & db.Relations.Item(i).Properties.Item(j).Name
                WScript.echo j & " PropertyValue:" & db.Relations.Item(i).Properties.Item(j).Value
            Next
       End if

       WScript.Echo "Table: " &            db.Relations.Item(i).Table
    Next 

End If

I had assumed that I could be clever and check the field counts and iterate through those. However the joke is on me as I made a relationship between two fields that do not share the same name and the field count remains 1. Thus my cleverness did not reveal to me the secret of mana 😛 Does anybody know how I can coax this information out?

  1. Table Name = db.Relations.Item.Table
  2. Table Field Name = db.Relations.Item.Fields.Item(0).Name
  3. Foreign Table Name = db.Relations.Item.ForeignTable
  4. Foreign Table Field Name = ????
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:14:57+00:00Added an answer on June 3, 2026 at 7:14 am

    You have this …

    " Field name: " & db.Relations.Item(i).Fields.Item(j).Name
    

    To retrieve the name of the related field in the foreign table, use this:

    " Foreign Field name: " & db.Relations.Item(i).Fields.Item(j).ForeignName
    

    Actually you don’t need to explicitly include .Item() to retrieve the ith or jth member of each collection. So I would shorten it to this:

    " Foreign Field name: " & db.Relations(i).Fields(j).ForeignName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to have my source control block in my ccnet.config file access
I am trying to add my project under source control. I am using Microsoft
We're interested in moving from a source control system that supports the concept of
We are coming from a Visual Source Safe background and are trying to look
I'd like to be able to source control my Excel spreadsheet's VBA modules (currently
I am preparing to move my team's source control from VSS over to TFS
I am trying to set up my organization's source control architecture for our Sage
My team is trying to run a script that is in source control to
I'm using NI's Labwindows CVI and I'm trying to integrate source control. Supposedly it
I'm trying to integrate our Source Control(SourceAnywhere) with VS and are getting a lot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.