VBA add data to linked tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bruce Heavner
    New Member
    • Feb 2012
    • 4

    #1

    VBA add data to linked tables

    I have 3 tables, with relationships like:
    Table1\Project (primary key)
    Table2\Project (link to Table1)
    Table2\StatusRe port
    Table2\Index (primary key)
    Table3\Index (link to table2)
    Table3\Notes

    All those are one to many relationships, so

    Table1 -> Table2 -> Table3
    I have a form that works to input data into these, and if I browse the raw tables I also can add the data, maintaining the links and all that. The question is - how can I do it in VBA? My goal is to import from current excel-based status reports specific cells into different places in all three tables. But I don't have a clue where to start actually adding the data to the tables. I've got the excel object side of things ok, and I can read the values I want - I just don't know how to put them where they go.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Always populate the One side of a One-to-Many link first. In this case import [Table1] data, followed by [Table2], followed by [Table3].

    Comment

    • Bruce Heavner
      New Member
      • Feb 2012
      • 4

      #3
      Right - I know that's how it works when using the table or form view, but how to I do that programatically in vba code?

      In other words, when I populate Table2 data, how do I make sure it is linked to the correct key in Table1?
      Last edited by NeoPa; Feb 4 '12, 09:55 PM. Reason: Merged into single post

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        The links are in the data itself. According to your question they are already set and in place. Why would you feel anything more than importing the data is necessary?

        Comment

        • Bruce Heavner
          New Member
          • Feb 2012
          • 4

          #5
          You're absolutely correct - I've been thinking about this off and on during the day, and it makes total sense. All I have to do is populate the link field right, and then everything will add up correctly. Sorry for the slow thinking, and thanks for the help.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32669

            #6
            You're sorted is all that matters Bruce :-)

            Besides, it's not at all unusual, even for experienced database workers, to get temporary blind-spots where the obvious is just invisible for a bit ;-)

            Comment

            Working...