title: Parameters in Microsoft Access
body: <p>I'm really confused with how parameters work in Microsoft Access.  I know that parameters are supposed to be used to allow a user to type in values when the query is run - instead of having to modify the query for each instance.</p>
  
  <p>So, let's use the following example.</p>
  
  <pre><code> SELECT countyTable.countyName, Sqr((69.1*(46.47-avgLatitude))^2+(69.1*(-90.17-avgLongitude)*Cos(avgLatitude/57.3))^2) as Distance
   FROM countyTable
   WHERE ((([avgLatitude]-5)&lt;46.47) AND (([avgLatitude]+5)&gt;46.47) AND (([avgLongitude]-5)&lt;-90.17) AND (([avgLongitude]+5)&gt;-90.17))
   ORDER BY Sqr((69.1*(46.47-avgLatitude))^2+(69.1*(-90.17-avgLongitude)*Cos(avgLatitude/57.3))^2), countyTable.countyName
  </code></pre>
  
  <p>1) I am SELECTing a column that contains the SQR function.  I also have that column named as 'Distance'.  However, when I try to ORDER BY on said column - and refer to it as 'Distance' - it asks for a value instead of sorting on that column.  The only way I can get the query to ORDER BY is to duplicate the expression from the SELECT line.  This seems unnecessary.</p>
  
  <p>2) Right now, I have some values hard-coded in.  I could care less about the values '57.3' and '69.1'  However, for '46.47' I would like to replace with 'x2' and -90.17 with 'y2'.  How I've been trying to write this with parameters, Access asks for values for each instance of 'x2' and 'y2'.  This doesn't help me at all, so I have them hardcoded in.</p>
  
  <p>Any help at all?  Thanks!</p>