How to relate one table to two other tables each with a one-to-many relationship?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mo Ewing
    New Member
    • Feb 2011
    • 8

    How to relate one table to two other tables each with a one-to-many relationship?

    I have one table called "Plants" that has a many-to-many relationship with a table called "Locations" through a third table called "PlantsToLocati ons". This setup works fine. I have a form where I can open a location and enter a list of all the plants found there.

    Now, the problem is that individual plants may have two (or more) scientific names and I want to be able to search a name field for either name. So I tried to set up a second one-to-many relationship between the "Plants" table and a new table called "Species", but no matter how I attach the Species Table to the Plants Table, I cannot get it to work.

    Is it possible attach one table to two other tables each with a one-to-many relationship?
  • RuralGuy
    Recognized Expert Contributor
    • Oct 2006
    • 375

    #2
    Does every table have an AutoNumber as a PrimaryKey?

    Comment

    • Mo Ewing
      New Member
      • Feb 2011
      • 8

      #3
      Yes. Species has speciesID as an AutoNumber and PrimaryKey, Plants has one called PlantsID, PlantsToLocatio n has PlantsToLocatio nID, and Locations has LocationsID.

      Comment

      • RuralGuy
        Recognized Expert Contributor
        • Oct 2006
        • 375

        #4
        Any chance you can post a picture of your relationships? Something does not sound right.

        Comment

        • Mo Ewing
          New Member
          • Feb 2011
          • 8

          #5
          Access will produce a PDF of the relationships table but I don't know how to attach it to this message.

          Comment

          • RuralGuy
            Recognized Expert Contributor
            • Oct 2006
            • 375

            #6
            After going to Advanced then scroll down to Manage Attachments. If it is too big then ZIP it up first.

            Comment

            • Mo Ewing
              New Member
              • Feb 2011
              • 8

              #7
              Here is a jpeg of the table relationships.
              Attached Files

              Comment

              • RuralGuy
                Recognized Expert Contributor
                • Oct 2006
                • 375

                #8
                Why are there two tables with Species_Name fields?

                Comment

                • Mo Ewing
                  New Member
                  • Feb 2011
                  • 8

                  #9
                  The Species_Name in the Plants table is where the Species_Name used to be, so that field will be deleted when I get the Species Table set up and working. Sorry, I should have taken it out for this discusion.

                  Comment

                  • RuralGuy
                    Recognized Expert Contributor
                    • Oct 2006
                    • 375

                    #10
                    You should be able to use an OUTER JOIN (LEFT OR RIGHT) and get all of the Species_Names in your query.

                    Comment

                    • Mo Ewing
                      New Member
                      • Feb 2011
                      • 8

                      #11
                      The querys do work! I think what I was doing was testing the queries by stringing them all together, and when I tried to enter data I got an error message saying,"Field not up-datable". But if I enter data into one query with Species and Plant data, and close it, then I can enter Plant and location data.

                      In any case, you have solved my problem. Thank you.

                      Mo

                      Comment

                      • RuralGuy
                        Recognized Expert Contributor
                        • Oct 2006
                        • 375

                        #12
                        Excellent! Thanks for posting back with your success.

                        Comment

                        Working...