Ok I have looked all over the forum for this but can't find a good answer. I have seen mention of a UNION query but not sure how and if that would work here.
I have a from with multiple combo boxes to select criteria for a report. The below SQL statement works great but for records that have multiple Activities or multiple Types, I get the parent record (Location) multiple times. I hope that makes sense.
For example, I pick a community, a boro, and a type. If the returned records have multiple activites attached to it then i get that record multiple times for each activity. It does the same thing if you select an activity and no type. Activity and Type are my two many-to-many relationships/tables. How can i get it to give my just the records that fit in the select community, boro and type regardless of the activitys involved?
Hope i explained it well enough... Thanks
Mike
I have a from with multiple combo boxes to select criteria for a report. The below SQL statement works great but for records that have multiple Activities or multiple Types, I get the parent record (Location) multiple times. I hope that makes sense.
Code:
SELECT tblLocation.*, tblCommunity.comm_name, tblBoro.Boro_name,
tblLocation_type.loc_type_name, tblActivities.act_name
FROM ((tblCommunity INNER JOIN (tblBoro INNER JOIN tblLocation ON
tblBoro.Boro_id=tblLocation.loc_boro) ON
tblCommunit.comm_id=tblLocation.loc_comm) INNER JOIN (tblActivities
INNER JOIN tblLINKloc_act ON tblActivities.act_id=tblLINKloc_act.act_id)
ON tblLocation.location_id=tblLINKloc_act.location_id) INNER JOIN
(tblLocation_type INNER JOIN tblLINKloc_type ON
tblLocation_type.loc_type_id=tblLINKloc_type.loc_type_id) ON
tblLocation.location_id=tblLINKloc_type.location_id
WHERE ((([comm_name]=forms!frmRptSelect!cmbComm OR forms
frmRptSelect!cmbComm Is Null)=True) AND (([Boro_name]=forms
frmRptSelect!cmbBoro OR forms!frmRptSelect!cmbBoro Is Null)=True) AND
(([loc_type_name]=forms!frmRptSelect!cmbType OR forms!frmRptSelect
cmbType Is Null)=True) AND (([act_name]=forms!frmRptSelect!cmbAct OR
forms!frmRptSelect!cmbAct Is Null)=True));
For example, I pick a community, a boro, and a type. If the returned records have multiple activites attached to it then i get that record multiple times for each activity. It does the same thing if you select an activity and no type. Activity and Type are my two many-to-many relationships/tables. How can i get it to give my just the records that fit in the select community, boro and type regardless of the activitys involved?
Hope i explained it well enough... Thanks
Mike