I'm using a database which contains a Staff table and a Groups table, what I'm trying to do is so that each staff member can be a member of many groups and each group can contain multiple staff, many-to-many relationship. I also have a join table connecting the two (below is my table structure). Both the Staff and the Groups table have a one-to-many relationship with the Group Staff table.
Staff Table
Staff ID
First Name
Last Name
Group Table
Group ID
Group Name
Group Staff Table
Group Staff ID - PK
Group ID - FK
Staff ID - FK
What I'm trying to do is in the Groups Table, I have a field called "Members" which should contain all the staff (looked up from the staff table) who are members of the group. I'm using a lookup field to display all the Staff members. The problem is that I can't select multiple staff for each group, which I need to.
If I try and change the lookup field to "Allow multiple values" then it tells me I can't because of the relationship between the Staff and the Group table, but of course I need the relationship to be able to lookup the Staff members.
So how can I make it so I can can have a lookup field in the Group table that allows me to select multiple Staff from the Staff Table? Any help is appreciated.
You can't do it the way you've describe.
With a Group
and Staff
table, if you want a many-to-many relationship, you do (as you state) have to have a joining table (GroupStaff
). However, you can't really create the relationships on either the Group
or Staff
tables.
You have to create new rows in the GroupStaff
table. You can do this manually on row at a time, of if I'm creating a an app, I'll generally have a form with two sub forms. The parent form would be bound to Group
in this case, and the subforms would be bound to Staff
and GroupStaff
respectively. You can then add controls (buttons) to add records to the GroupStaff
table base on what records were selected in the Group
form and the Staff
subform.
The GroupStaff
subform would also be filtered to show only the records associated with the group currently on the parent from.