P
Paul James
I'm trying to build a query for the recordset of a report that will contain
three subreports. The four tables involved are related as follows:
tblLbranch <--- tblLicensee ---> tblAgent ---tblAgentBranch
So tblLicensee has a one to many relationship with both tblLbranch and
tblAgent, and tblAgent has a one to many with tblAgentBranch. The report
will be structured so that tblLicensee provides the data for the main form,
while the three other tables are contained in the three subforms.
The one field common to all four tables is LicenseeID.
The problem arises when I try to create the query for the main report. The
recordsets for each of the three subreports are of course based on criteria
applied to each table separately, and I've easily created those three
(sub)queries. But the recordsets for each of the subreports generally
involve different licensees; and I need the query for the main report to
produce a recordset that includes all of the licensees from the three
subreports. What it's doing at present, however, is displaying only those
licensees that are contained in ALL the subreports. In other words, if a
licensee exists in one subreport but not in another, that licensee doesn't
appear in the main report. I need all of them.
I know how to accomplish this using some append queries to create some
temporary records, then delete them, but this creates holes in the file that
need to be compressed, and if I could do this with a select query, I'd much
rather do that.
I'm a sql weenie, so I've tried to do this with the qbe grid. But it hasn't
worked so far. I'll try to diagram what I've done in the qbe grid, and
hopefully someone can tell me a way to modify it so it will work.
field1 field2 field3
subquery1 subquery2 subquery3
criteria1
criteria2
criteria3
I don't know how much of the foregoing layout will survive the reformatting
in the news server, but what I'm attempting to display is that I'm trying to
get the query to produce the records containing the LicenseeID from all 3
subreports by putting the criteria from each of the three (sub)queries on
separate criteria lines. The heading to the left of these criteria lines is
labeled "or," and I would have expected to thus include ALL the licensee
records from the subqueries. Instead, it's only displaying the LicenseeIDs
that are contained in all three underlying queries.
I would have expected this if I had put the three criteria on the same line
(since this would be an "AND" condition), but when I do that, I get no
records at all.
Can anyone tell me if there's a way to get the query for the main query to
produce records containing the LicenseeID fields contained in all three
subqueries?
Thanks in advance.
Paul
three subreports. The four tables involved are related as follows:
tblLbranch <--- tblLicensee ---> tblAgent ---tblAgentBranch
So tblLicensee has a one to many relationship with both tblLbranch and
tblAgent, and tblAgent has a one to many with tblAgentBranch. The report
will be structured so that tblLicensee provides the data for the main form,
while the three other tables are contained in the three subforms.
The one field common to all four tables is LicenseeID.
The problem arises when I try to create the query for the main report. The
recordsets for each of the three subreports are of course based on criteria
applied to each table separately, and I've easily created those three
(sub)queries. But the recordsets for each of the subreports generally
involve different licensees; and I need the query for the main report to
produce a recordset that includes all of the licensees from the three
subreports. What it's doing at present, however, is displaying only those
licensees that are contained in ALL the subreports. In other words, if a
licensee exists in one subreport but not in another, that licensee doesn't
appear in the main report. I need all of them.
I know how to accomplish this using some append queries to create some
temporary records, then delete them, but this creates holes in the file that
need to be compressed, and if I could do this with a select query, I'd much
rather do that.
I'm a sql weenie, so I've tried to do this with the qbe grid. But it hasn't
worked so far. I'll try to diagram what I've done in the qbe grid, and
hopefully someone can tell me a way to modify it so it will work.
field1 field2 field3
subquery1 subquery2 subquery3
criteria1
criteria2
criteria3
I don't know how much of the foregoing layout will survive the reformatting
in the news server, but what I'm attempting to display is that I'm trying to
get the query to produce the records containing the LicenseeID from all 3
subreports by putting the criteria from each of the three (sub)queries on
separate criteria lines. The heading to the left of these criteria lines is
labeled "or," and I would have expected to thus include ALL the licensee
records from the subqueries. Instead, it's only displaying the LicenseeIDs
that are contained in all three underlying queries.
I would have expected this if I had put the three criteria on the same line
(since this would be an "AND" condition), but when I do that, I get no
records at all.
Can anyone tell me if there's a way to get the query for the main query to
produce records containing the LicenseeID fields contained in all three
subqueries?
Thanks in advance.
Paul