title: VBA retrieve errors found in running query with DoCmd.RunQuery
body: <p>I'm running a bunch of MS-Access querys from a VBA script using DoCmd.RunQuery, some of this querys when runned directly give errors of the kind "MS Access could not add XX registers due to ... " and I would like to get a log of them. </p>
  
  <p>Something like</p>
  
  <pre><code>DoCmd.RunQUery "query 1"
  If "There is an Error" Then
      Debug.Print "error message"
  End If
  </code></pre>
  
  <p>And I would like to know how I can implement "There is an error" and "error message" parts. Thanks.</p>