Results 1 to 6 of 6
  1. #1
    ktj is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    3

    Many to Many form

    Hi All,



    I have been looking at this example of a many to many database complete with forms. http://www.databasedev.co.uk/many_to_many_example.html (it allows you to download the sample db)

    What I dont understand is how the forms were created. When i try to do something similar i can't get the forms to work in the same way.

    For those who dont want to download the file the problem is this. This is a DB which allows details of a music collection to be stored. In one form it allows you to view an artist and in the sub form add a related album. Alternatively you can view a form that shows the album details but in the sub form you can add a related artist.

    The problem i have is trying to work out what tables the forms were based on. When I try to do it, it looks the same but I am unable to change any of the sub form data. Which of the 3 tables need to be included 'album', 'artist' and/or the junction table?

  2. #2
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    The junction table relates the artists and the albums, so basically you need all three tables to make the relationships. In terms of forms, in either case, the subform is based on the junction table. If you want to view an artist with all of their associated albums, then the main form should be based on the artist table. Again, the subform would be based on the junction table. If you want to view albums with all associated artists, then the main form should be based on the albums table (subform based on the junction table once again).

  3. #3
    ktj is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    3
    Thanks. I understand how to view the associated data using the either album or artist as the main form and the junction table as the subform.

    What I dont understand is how you add new associations in the subform.

    In the example DB, when viewing the Artist Details as the main form, you are able to add new album associations in the sub form by simply choosing one in the drop down.

    How do you set up the subform to allow users to add new associations (e.g. choose a new album for a particular artist).

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The "magic" is performed by utilizing the ability of a ComboBox to bind a column of the RowSource of the cbo to a field of the RecordSource of the Form (a query) by using the ControlSource of the cbo. No additional coding is needed.

  5. #5
    ktj is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    3
    I understand the mechanics of what you are saying its just I'm getting confused on what specifically the sub form should be based on (just the junction table or a query which is a mix of both the junction and one of the others) and also which fields and tables im pointing to when i create my combo boxes.

    I know where to change the column/row source etc I just don't know what fields I should be connecting to.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The SubForm RecordSource is what controls what you can display on the SubForm. That is simply your decision.

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

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