foxtrot123
Registered User.
- Local time
- Today, 11:23
- Joined
- Feb 18, 2010
- Messages
- 57
I am trying to create a delete query that, for a given person, deletes records in Table B that do not have a corresponding record in Table A.
Here are the relevant tables:
For example, pretend that tblStates shows that State IDs 1, 5, and 6 are all in Region ID (i.e., all have a RegionID = 10).
If Joe (PersonID = 200) has StateIDs 1, 5, and 6 in tblPeopleStates, but doesn't have a record for RegionID = 10 in tblPeopleRegions, I need to delete his three records in tblPeopleStates (i.e., the ones where StateID = 1, 5, and 6).
PersonID will be found on [Forms]![frmMain]![subform1].[Form]![subform2].Form]![PersonID]
Any suggestions about building this query?
Here are the relevant tables:
- tblStates holds StateID, StateName, and RegionID (RegionID is a FK to tblRegions).
- tblPeopleStates is a junction table between tblPeople and tblStates. It lists states assigned to people. It has 3 fields: PersonStateID, PersonID, StateID.
- tblPeopleRegions is a junction table between tblPeople and tblRegions. It lists regions assigned to people. It has 3 fields: PersonRegionID, PersonID, RegionID.
For example, pretend that tblStates shows that State IDs 1, 5, and 6 are all in Region ID (i.e., all have a RegionID = 10).
If Joe (PersonID = 200) has StateIDs 1, 5, and 6 in tblPeopleStates, but doesn't have a record for RegionID = 10 in tblPeopleRegions, I need to delete his three records in tblPeopleStates (i.e., the ones where StateID = 1, 5, and 6).
PersonID will be found on [Forms]![frmMain]![subform1].[Form]![subform2].Form]![PersonID]
Any suggestions about building this query?