Microsoft Access problem

Flori Gashi 1 Reputation point
2022-12-11T23:35:16.713+00:00

How to add two IDs in one field, for example a student table has a ParentID field thats connected to another table “Parents”, but the student has two parents, so how do I add both numbers in one box? It doesnt let me.

Microsoft 365 and Office | Access | Development
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Gustav 722 Reputation points MVP
    2022-12-12T08:32:11.22+00:00

    You don't.
    Either have two fields, Parent1 and Parent2; or a junction table, Parentship, from which you have one ID to the student, and to which you can connect multiple parents.

    0 comments No comments

  2. Ken Sheridan 3,296 Reputation points
    2022-12-12T12:46:36.613+00:00

    The relationship type between children and parents is many-to-many, in that each child can have more than one parent and each parent can have more than one child. This is modelled by a table which resolves the relationship type into two one-to-many relationship types:

    Parentage
    ….StudentID (FK)
    ….ParentID (FK)

    The primary key of this table is a composite of the two foreign keys. You might also want to add a further foreign key, RelationshipID, referencing the primary key of a Relationships table with values such as Mother, Father, Guardian, etc.

    For an example of a basic many-to-many relationship type like this you might like to take a look at ParentActivities.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    If you have trouble downloading a specific file, clicking on the 'Download' button at the top of the page while no files are selected should download a zip file of all files in the folder, from which you should then be able to unpack the relevant file.

    In this little demo Activities is analogous to Students in your table. The Parents by Activity form illustrates the interface for entering multiple parents per activity by means of a subform based on the ParentActivities table. In your case it would be based on the Parentage table and embedded in a Students form.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.