I have an SQL query to get the names of the heads of the house. Sometimes there will be two (male and female), sometimes there will be one (either single male or single female).
The male's name is gathered in "Role1QRY".
The female's name is gathered in "Role2QRY".
The result should look like: George & Gracie Burns or Stevie Wonder or Linda Carter
June7 was nice enough to help me, but the following query has a few issues:
1) It pulls the man's name (from Role1QRY) and always adds the ampersand (&) even if there isn't a female (Stevie & Wonder).
2) It doesn't give the IndID for single females (the field is blank).
I've tried to make adjustments, but it is apparent I'm over my head.
SELECT Role1QRY.IndID, [Role1QRY].[FirstName] & IIf(IsNull([Role1QRY].[FirstName]),""," & ") & [Role2QRY].[FirstName] & " " & [FamilyLastName] AS FiledAs
FROM Role1QRY RIGHT JOIN (Role2QRY RIGHT JOIN FamilyTBL ON Role2QRY.[IndID] = FamilyTBL.ID) ON Role1QRY.[IndID] = FamilyTBL.ID;
Note:
There are two tables: FamilyTBL and IndividualTBL. There is a main form (FamilyFRM) and a subform (IndividualFRM).
Key:
FamilyFRM - The main form
IndividualFRM - The subform
FamilyTBL - The table for family information
IndividualTBL - The table for inidividual information
ID - FamilyTBL primary key
IndID - IndividualTBL number linked to FamilyTBL:ID (one to many)
FamilyLastName - FamilyTBL field for the last name of the family (not necessarily the individual)
FirstName - IndividualTBL field for the first name
Role1QRY - the query to get the first name of the "male"
Role2QRY - the query to get the first name of the "female"