I made assumptions about what your field names are, you'll need to modify the code below. This sql will return a count of main numbers and emails for each person in the people table.
Code:
SELECT
tblPeople.ID,
tblPeople.FirstName,
(
SELECT
Count(*)
FROM
tblPhoneNumbers
WHERE
PersonID = tblPeople.ID
AND IsMain = True
)
AS MainPhoneNumbers,
(
SELECT
Count(*)
FROM
tblEmails
WHERE
PersonID = tblPeople.ID
AND IsMain = True
)
AS MainEmails
FROM
tblPeople;
EDIT:
The following sql will only return the people with invalid counts:
Code:
SELECT
qryMainCount.ID,
qryMainCount.FirstName,
qryMainCount.MainPhoneNumbers,
qryMainCount.MainEmails
FROM
(
SELECT
tblPeople.ID,
tblPeople.FirstName,
(
SELECT
Count(*)
FROM
tblPhoneNumbers
WHERE
PersonID = tblPeople.ID
AND IsMain = True
)
AS MainPhoneNumbers,
(
SELECT
Count(*)
FROM
tblEmails
WHERE
PersonID = tblPeople.ID
AND IsMain = True
)
AS MainEmails
FROM
tblPeople
)
AS qryMainCount
WHERE
(
((qryMainCount.MainPhoneNumbers) <> 1)
)
OR
(
((qryMainCount.MainEmails) <> 1)
)
;
Then in your vba if that returns anything you know you need to cancel the form close