title: query in Vba using cdate function with variable
body: <p>Using the following query in microsoft access sql view works nice and easy with a hard coded date</p>
  
  <blockquote>
  <pre><code>SELECT Salary.First, Salary.Last,FROM Salary, allowances
  WHERE Salary.PayThroughDate = CDate("2014-05-06") AND Salary.SSN = allowances.SSN
  </code></pre>
  </blockquote>
  
  <p>but embedding this query in Vba using a variable instead of a hard coded date is another business. It is just not working:</p>
  
  <blockquote>
  <pre><code>Dim ddate As Variant
  Dim getDay As Integer
  Dim getMonth As Integer
  Dim getYear As Integer
  getDay = Day(Me.DTPicker2.Value)
  getMonth = Month(Me.DTPicker2.Value)
  getYear = Year(Me.DTPicker2.Value)
  ddate = getDay &amp; "/" &amp; getMonth &amp; "/" &amp; getYear
  ddate = Format(ddate, "dd/mm/yyyy")
  
  query1 = "SELECT Salary.First, Salary.Last FROM Salary, allowances WHERE Salary.PayThroughDate =  " &amp; CDate(ddate) &amp; " AND Salary.SSN =
  </code></pre>
    
    <p>allowances.SSN</p>
  </blockquote>
  
  <p>Any ideas in this Vba Sql mix? Am I missing single or double quotes?</p>