title: Query with data from subform and sum
body: <p>I have three tables:</p>
  
  <pre><code>Products(ID,Name,Price) / 
  Customer(ID, Name, Surname)
  Buys(ID, ID_customer, ID_product)
  </code></pre>
  
  <p>I have a form with subform. Subform gets populated with query from Buys table and then connected to Customer(ID) via ID_customer. ID and ID_customer gets hidden on subform.</p>
  
  <p>Then I have two more fields/controls added on subform: Name and aPrice which gets populated via ProductsQuery: </p>
  
  <pre><code>SELECT Products.Name, Products.Price
  FROM Products
  WHERE (((Products.ID)=[Forms]![PregledKupcev-Form]![NAKUPI-Subform]![ID])); 
  </code></pre>
  
  <p>//ID in this case is control on subform which holds ID of a product</p>
  
  <p>using:</p>
  
  <pre><code>=DLookUp("[Name]";"[ProductsQuery]")
  </code></pre>
  
  <p>and</p>
  
  <pre><code>=DLookUp("[Price]";"[ProductsQuery]")
  </code></pre>
  
  <p>So far everything works but it gives me alot of troubles later when i try to sum one control (Price in this case).</p>
  
  <p>Is there any way to do this better?</p>
  
  <p>Then I try to sum up things in aPrice control into PriceSum control on subform's footer:</p>
  
  <pre><code>=Sum([Forms]![PregledKupcev-Form]![NAKUPI-subform]![aPrice])
  </code></pre>
  
  <p>and transfer it to form with:</p>
  
  <pre><code>=[Forms]![PregledKupcev-Form]![NAKUPI-subform]![PriceSum]
  </code></pre>
  
  <p>but I get error..</p>
  
  <p>How do I sum up values in Price control on subform?</p>
  
  <p>Pictures:
  <img src="https://i.stack.imgur.com/ln85Z.png" alt="Form"></p>