Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <strong>UNION</strong> query is intended to be used when you want to retrieve data from different tables but with the same structure.</p> <p>In your situation, I think the best solution is a <strong>JOIN</strong> query, like </p> <pre><code>SELECT M.field1, M.field2, M.field3, H.field1, H.field2 ...whatever fields you need FROM Managers as M LEFT OUTER JOIN [Design Hours Table] as H ON H.Person = M.PersonID ORDER BY ... whatever order you want </code></pre> <p>You can use this query as <em>RowSource</em> for a report, telling Access to group the results by all the fields in the Managers table.</p> <p>But if you are using that for a form, then you can use a <strong>Form/Subform</strong> combination.</p> <p>You set your original query as the <em>RowSource</em> of the form, and design it with all the desired fields and labels. Then you insert a <em>SubForm</em>, </p> <p><img src="https://i.stack.imgur.com/51yHJ.png" alt="Adding a Subform"></p> <p>and tell Access to use an existent table or query for the subform data, then choose the <em>Design Hours</em> table for that, and select to show records in Design Hours for each record in <em>Managers</em> using the field <em>PersonID</em>.</p> <p>Now, there is another issue I wanted to comment: You have a <em>PersonID</em> field in the <em>Managers</em> table, which is correct, since a manager <strong>IS A</strong> person. What is incorrect in your design is the existence of a <em>FirstName</em> and <em>LastName</em> columns in the Managers table (unless it is not really a table, but a query). The reason is that the <em>PersonID</em> defines a set of properties, <em>FirstName</em> and <em>LastName</em> being among them. So, with your design, you could end up with a manager having <em>PersonID</em> = 2013, <em>FirstName</em> = John, <em>LastName</em> = O'Connor and the ID 2013 in the People table referring to <em>FirstName</em> = Peter, <em>LastName</em> = Sellers, which would be an inconsistency. </p> <p>Also, you don't need an ID in this table, since the field PersonID is best fitted to serve as PK for this table.</p> <p>You retrieve the Name and SurName from the People table, so the join would be something like</p> <pre><code>SELECT M.field1, M.field2, M.field3, P.FirstName, P.LastName, H.field1, H.field2 ...whatever fields you need FROM (Managers as M INNER JOIN People as P ON P.ID = M.PersonID) LEFT OUTER JOIN [Design Hours Table] as H ON H.Person = M.PersonID ORDER BY ... whatever order you want </code></pre> <p>Regards,</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload