title: Can I have a DoCmd method in IF statement?
body: <p>I have the following VBA code for a .mdb Access file:</p>
  
  <pre><code>If DoCmd.RunSQL "SELECT DISTINCT Max(wk_ending_dt) FROM d2s_loader_performance" &lt; (Date()-Weekday(Date())) Then
      DoCmd.RunSQL "DELETE * FROM d2s_loader_performance_tbl WHERE wk_ending_dt = (Date()-Weekday(Date())-35)"
  End If
  </code></pre>
  
  <p>It then highlights the following text: <code>"SELECT DISTINCT Max(wk_ending_dt) FROM d2s_loader_performance"</code> And gives the error <code>Compile Error: Expected Then or GoTo</code>.</p>
  
  <p>Any ideas?  I have a Then at the end of my conditional check, and to my understanding the double quotes are just for the SQL syntax.  I'm using this <code>If...Then</code> condition to only allow record deletion if the max table date is less than the previous week's ending date.</p>