title: MS Access - Problems using variables in WHERE clause
body: <p>I have a working query which takes too long to run. It is being used to populate an Access form field with a list of distinct contracts ordered by their start date.</p>
  
  <p>The following query returns a list of distinct contract start dates for multiple commodities (which share contract start dates) where the contract start date (DELSTART) is greater or equal to the current date (PRICEDATE). </p>
  
  <p>The function returndelivery returns a date attribute of the contract converted to a double, the function returnnumericdate just returns a double from a date (yyyymmdd).</p>
  
  <pre><code>SELECT DISTINCT (tblFuturesPrices.Period),
         returnnumericdate(returndelivery([PERIOD],"S")) AS DELSTART,
         ReturnNumericDate(Date()) AS PRICEDATE
  FROM tblFuturesPrices
  WHERE returnnumericdate(returndelivery([PERIOD],"S")) &gt;= ReturnNumericDate(Date())
  GROUP BY PERIOD
  ORDER BY returnnumericdate(returndelivery([PERIOD],"S"));
  </code></pre>
  
  <p>Ideally I would like to refer to the variables DELSTART and PRICEDATE in the where clause but Access prompts for a variable value when I do so. I think the query takes longer than it should because I'm having to use my user defined functions numerous times. </p>
  
  <p>The source table (tblFutures) contains prices for each commodity / contract for working days going back 6 months.</p>
  
  <p>Thanks in advance.</p>