title: Using VBA to set the parameters of a query
body: <p>So I have a query, as shown below, which runs on a parameter.</p>
  
  <p>I was wondering if there is a way to use VBA to set the query parameters.  I currently have about 40 queries all exactly the same except for the product ID, and as such I have 40 reports as well...  if i have the one query, I will still have to write out the code for the productid in the VBA, but i can use one report instead of that many.</p>
  
  <p>Life would be much easier with just one query and one report and have the VBA set the parameters, as the user does not know the product ID</p>
  
  <pre><code>SELECT TblTotalSale.ProductID, TblProduct.Description, TblTotalSale.Size, TblTotalSale.SalePrice, TblTotalSale.Day
  FROM TblProduct INNER JOIN TblTotalSale ON TblProduct.ProductID = TblTotalSale.ProductID
  WHERE (((TblTotalSale.ProductID)=[]));
  </code></pre>
  
  <p>The VBA</p>
  
  <pre><code>Private Sub IPA_Click()
  
  DoCmd.OpenReport "RptProduct", acViewReport, , [TblTotalSale.ProductID="5"]
  
  End Sub
  </code></pre>
  
  <p>I have also tried tblTotalSale.ProductID = "5"
  I know I am using SQL where I should be using VBA...</p>
  
  <p>Thanks</p>
  
  <p>Sam</p>