ok i'm not much of a SQL girl. but here's answer using queries.
the gist to make sure i'm understanding right: i made a query which creates all possible combinations of Resources and Teams (qryTeamResourceCombo). I compare this to the tblTeamResources to figure out what Teams and Resources are still available to pick from and make these the underlying queries for the combo boxes when opening the form. so, when opening the form (and when moving to a new record) the combo boxes are not populated with tblTeam and tblResources, but of the results of the above queries (TEAMS which still can be chosen and Resources which still can be chosen). Then, once either combo box is changed (OnChange event) i change the RowSource of the opposite combo box to only show items which are not yet selected for that team or resource. right?
i know this is a lot, but it works right. i put all queries into SQL so you can build them.
i made three tables as you described above.
then:
1) qryTeamResourceCombo
SQL =
Code:
SELECT tblTeam.TeamKey, tblResource.ResourceKey
FROM tblTeam, tblResource;
2a) qryAvailableTeamsAll Teams that are available to choose from
SQL =
Code:
SELECT DISTINCT qryTeamResourceCombo.TeamKey, tblTeam.TeamName
FROM (qryTeamResourceCombo LEFT JOIN tblTeamResource ON (qryTeamResourceCombo.TeamKey = tblTeamResource.TeamID) AND (qryTeamResourceCombo.ResourceKey = tblTeamResource.ResourceID)) INNER JOIN tblTeam ON qryTeamResourceCombo.TeamKey = tblTeam.TeamKey
WHERE (((tblTeamResource.ResourceID) Is Null));
2b) qryAvailableResourcesAll Resources that are available to choose from
SQL =
Code:
SELECT DISTINCT qryTeamResourceCombo.ResourceKey, tblResource.ResourceName
FROM (qryTeamResourceCombo LEFT JOIN tblTeamResource ON (qryTeamResourceCombo.ResourceKey = tblTeamResource.ResourceID) AND (qryTeamResourceCombo.TeamKey = tblTeamResource.TeamID)) INNER JOIN tblResource ON qryTeamResourceCombo.ResourceKey = tblResource.ResourceKey
WHERE (((tblTeamResource.TeamID) Is Null));
3) frmTeamResource
cbo box 1: name = TeamID
RowSource = qryAvailableTeams
Column Count = 2; ColumnWidths = 0";1"
in TeamID OnChange Event (set ResourceID combo box to only show what Resources are available for the just-chosen Team)
Code:
Me.ResourceID.RowSource = "qryResourceWOTeam"
Me.ResourceID.Requery
cbo box 2: name = ResourceID
RowSource = qryAvailableResources
Column Count = 2; ColumnWidths = 0";1"
in ResourceID OnChange Event (set Team combo box to only show what Teams are available for the newly-chosen Resource)
Code:
Me.TeamID.RowSource = "qryTeamWOResource"
Me.TeamID.Requery
4a) qryChosenResource SQL =
Code:
SELECT tblTeamResource.TeamID, tblTeamResource.ResourceID
FROM tblTeamResource
WHERE (((tblTeamResource.ResourceID)=[Forms]![frmTeamResource]![ResourceID]));
4b) qryChosenTeam SQL =
Code:
SELECT tblTeamResource.TeamID, tblTeamResource.ResourceID
FROM tblTeamResource
WHERE (((tblTeamResource.TeamID)=[Forms]![frmTeamResource]![TeamID]));
5a) qryResourceWOTeam SQL =
Code:
SELECT tblResource.ResourceKey, tblResource.ResourceName
FROM tblResource LEFT JOIN qryChosenTeam ON tblResource.ResourceKey = qryChosenTeam.ResourceID
WHERE (((qryChosenTeam.ResourceID) Is Null));
5b) qryTeamWOResource SQL =
Code:
SELECT tblTeam.TeamKey, tblTeam.TeamName
FROM tblTeam LEFT JOIN qryChosenResource ON tblTeam.TeamKey = qryChosenResource.TeamID
WHERE (((qryChosenResource.TeamID) Is Null));
6)
in the form's OnCurrent event (re-setting combo boxes to same as orig RowSource whenever go to a diff record):
Code:
Me.TeamID.RowSource = "qryAvailableTeams"
Me.ResourceID.RowSource = "qryAvailableResources"
Me.TeamID.Requery
Me.ResourceID.Requery
whew. ok, so i know it's long but from what i understand, it's what you want. just make the stuff like i listed and you'll see. maybe you can improve on it or whatever, but this will get you there nonetheless.
good luck--g