Note that there are some explanatory texts on larger screens.

plurals
  1. POMS Access SQL query on setting variables?
    text
    copied!<p>HI Is it possible to store a variable to allow me to use the dates from a previous prompt? For example if i prompt a user for 2 dates like this: - </p> <pre><code>WHERE LatestGamma.ConfirmedPortingDate Between [Please Provide 1st Date (dd/mm/yyyy)] And [Please Provide 2nd Date (dd/mm/yyyy)]; </code></pre> <p>and then i want to use the same dates from the prompted ConfirmedPorting dates like this: - <code>AND LatestGamma.ProposedPortingDate Between [VariableName1stDateFromPrompt] And [VariableName2ndDateFromPrompt];</code> </p> <p>Can this be done with access?</p> <p>Here is my modified code after speaking with Gord and still does not work as expected, its errors if i leave the parameters in and runs if i take them out, but the results pull in records that dont meet the criteria IE Confirmed and proposed date are both different from the prompted ones:</p> <pre><code> PARAMETERS [Please Provide 1st Date (dd/mm/yyyy)] DateTime, [Please Provide 2nd Date (dd/mm/yyyy)] DateTime; SELECT LatestGamma.OrderId, LatestGamma.MainNumber, LatestGamma.LineType, LatestGamma.Company, LatestGamma.CPStatus, LatestGamma.ConfirmedPortingDate, LatestGamma.ProposedPortingDate, LatestGamma.RequestedDate FROM LatestGamma WHERE LatestGamma.ConfirmedPortingDate Between [Please Provide 1st Date (dd/mm/yyyy)] And [Please Provide 2nd Date (dd/mm/yyyy)] OR LatestGamma.ProposedPortingDate Between [Please Provide 1st Date (dd/mm/yyyy)] And [Please Provide 2nd Date (dd/mm/yyyy)] ORDER BY LatestGamma.Company; </code></pre>
 

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