Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    AshokS is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Posts
    9

    How to code master detail relation in tabforms

    Dear forum member,

    Can you tell me how to program a master detail relation in the Ms Access tabforms?

    The master form is a patient forum, with all information of a patient.



    The detail subform (a tabform) holds the related patient information, such as phone numbers.

    Question:
    If I click on a patient in the master form, I would like to see the related phone numbers in the subform.

    Can you tell me which trigger should be programmed and how to program this behavior?

    Many thanks.

    regards

    Ashok

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Generally this does not need to be coded. The master/child links are properties of the subform control; they would usually be set when the subform is added (the wizard will ask about linking fields, or they can be set manually).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    AshokS is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Posts
    9

    In the tabpage the master detail relation is not automatically set by the wizard

    In the tabpages wizard, the master detail relation is not automatically set by the wizard. IN the subform is is indeed automatically set.

    Can I send you the screens / forms or access file?

    regards
    Ashok

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Not sure what you mean. Tab controls are irrelevant regarding master/child links, as a tab control has nothing to do with data itself. Perhaps it would make more sense for you to post your db, or a sample of what you're trying to do.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    AshokS is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Posts
    9
    Hello Paul, please find attached the db file.

    If you open the file, you will see in the left under corner a form "TabPatienten".

    Open it in the designmode.

    Then you will see different tabforms. The first tabform is 'Patienten' and the second one is 'Verzekeringsgegevens'. Patienten is the master form whereas 'Verzekeringsgegevens' is the detail form. So whenever a patient record gets the focus or is clicked on, its related detail 'verzekeringsgegevens' should be shown if the user clicks on that tabform.

    I woud much appreciate if you can show me how to program the code for these two forms or how to develop the master -detail relation between these two forms.

    If successfull, I will then do the same for the other tabforms.

    Many thanks.

    regards

    Ashok

  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
    It would be very helpful if you define the relationships each table has with the others. You have 4 different SubForms that you are trying to keep in sync. That can be a bit tricky. Will everything drive off of the 1st tab or can the user switch by using one of the other tabs?

  7. #7
    AshokS is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Posts
    9
    The relationship between the tables:

    1) The first tabel is 'tblPatienten'. This table is related with the first tabpage, the master form

    2) All other tables are detail tables related with only the master table tblPatienten:

    TblPatienten and TblGeldigheidVerzekering have a 1 to many relationship. TblGeldigheidVerzekering is related with tabform 'Verzekeringsgegevens'

    TblPatienten and tblGarantiebrieven have a 1 to many relationship.
    tblGarantiebrieven is related with tabform 'Garantiebrieven'

    and so on.

    3) What behavior I would like to program? Only when a patient is selected in the first tabform or a record gets the focus, the detailforms (verzekeringsgegevens, garantiebrieven etc) should also show the related record. If a record is selected in one of the detail forms, no changes should be made in the other tabforms.

    4) I can tell you that the relationships at datamodel level are all well defined. The only thing I cannot get done, is the master detail relation in the tabforms.

    Let me know if it is clear now.

    Regards

    Ashok

  8. #8
    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
    You can define these relationships in the Relationship menu and then we could all see what you are talking about.

  9. #9
    AshokS is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Posts
    9
    please see attached the db file. IN this file you can read the relationships between defined tables.
    thx
    regards
    Ashok

  10. #10
    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
    Thank you. Much clearer. FYI, it is much easier to understand if you name the ForeignKeys the same name as in the table where they are a PrimaryKey. A descriptive name is also a benefit such as PatientenID rather than just ID. You've got them mixed in this db but it is now understandable. I'll do a little studying.

  11. #11
    AshokS is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Posts
    9
    Thanks for the tip, I will make those changes...foreignkeys and primary keys
    looking for your response
    regards
    Ashok

  12. #12
    AshokS is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Posts
    9
    Paul, I will log into the forum at 08 o clock in the morning again. It is already 1:30 in the morning in Suriname, time to go sleeping.
    thx, regards
    Ashok

  13. #13
    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
    Good night!

  14. #14
    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
    See if this is what you had in mind. It is done with an invisible control on the 1st tab and then the LinkChild/MasterFields propeties of the SubForms.

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by AshokS View Post
    Paul, I will ...
    Excellent! Allan is doing all the heavy lifting and I'm getting the credit!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Relation in three different tables
    By kzdev in forum Access
    Replies: 1
    Last Post: 11-22-2010, 03:12 AM
  2. Replies: 1
    Last Post: 11-12-2010, 08:14 AM
  3. Report based on query + sub-report (1:N relation)
    By BayerMeister in forum Reports
    Replies: 1
    Last Post: 08-19-2010, 03:26 AM
  4. Enable button in the master form when clicking in the detail
    By DistillingAccess in forum Programming
    Replies: 8
    Last Post: 08-03-2010, 10:54 AM
  5. Replies: 0
    Last Post: 05-09-2009, 09:04 PM

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