Home > other >  Showing records from a linked table in Access with FK depending on PK in linked table
Showing records from a linked table in Access with FK depending on PK in linked table

Time:01-22

I have two tables in Access, one table has person details where name is the PK and another table with multiple information entries with each date they were entered for each person where the name is the FK. I want to create a form that has a combo box with a list of names populated by the first table and something that will show all the records from the other table associated with that person including dates and information entries in like a list you can scroll through. Is this doable?

CodePudding user response:

Yes, it is doable. Very easy to design. As well there are several solutions. Assuming you have two tables, Persons and PersonsHistory, I will describe my preferred aproach:

  • Create a form MainForm
  • Add a combobox with the following properties
    • Name:PersonsCombo
    • RowSourceType: Table/Query
    • RowSource: Persons
    • BoundColumn: 1
    • ColumnCount: 2
    • ColumnWidths: 0";1"
  • Insert a Subform control
    • Choose "Use existing Tables and Queries"
    • Select Table:PersonsHistory as source
    • Add the required fields to the "Selected Fields"
    • Give the subform a name and finish the wizard
    • Set the LinkMasterFields to [PersonsCombo]
    • Set the LinkChildFields to PersonId

The following image is showing the final touch. enter image description here

The tables used for showcase enter image description here

The result with the subform as "Continuous forms" enter image description here

The result with the subform as "Datasheet" enter image description here

  •  Tags:  
  • Related