I am working on a simple database with two tables: Events and CAPs. There is a one to many relationship between them where the table CAPs has the foreign key EventID. At the moment the query I'm using to display all information in both tables uses a left outer join, the problem with this is that for each CAP associated with an event it repeats the event data. I would like to know if it's possible to make it display the data from each event only once when there are multiple CAPs. If this isn't something possible to do with queries I was thinking there might be a way to do it with the Report functionality of base.
What I get with my current query.
What I want to see.
Last edited by PunkintheGutter on Sun Sep 23, 2018 8:57 am, edited 1 time in total.
You can do that in a report, but not with queries.
On a form you can add your CAP data and on a subform you can add your Events, so that for the selected CAP the corresponding events are shown.
You can use your query as the data source for a report. Group records on the "EventID" and add the other fields you want to appear on the Header and put the rest in the Details area of the report.
I had seen a strategy for suppressing the display of query fields so I thought I would give it a try using tables structured according to what I saw on your included images.
First the records in "CAPs1" are grouped according to "EventID" and then ranked within the groups by "CAPID"
WHERE "e"."EventID" = "d"."EventID" AND "e"."CAPID" > "d"."CAPID" ) AS "RANK" FROM "CAPs1" AS "e"
I used that query to create "View01"
Then CASEWHEN statements can be used to suppress the display of fields in the final query based on their "RANK"
LEFT OUTER JOIN "View01" AS "V1"
The results look promising, but not all fields with CASEWHEN statements were suppressed.
Also any records in "Events1" that don't have at least one corresponding record in "CAPs1" don't display properly despite the Left Outer Join.
In an Embedded Base database when numeric values like "EventID" are NULL they are displayed as 0.
But even then, I've not found a way to suppress the display of Boolean fields.
All of which confirms the sage advice of eremmel.
Thanks for the help, I was trying to figure out how to group multiple fields on one level for a while when I realized how that grouping system sort of did what I want, but now I see that's much easier with the report builder.