title: Macro Error 2001 Autoexec Access Macro
body: <p>I have a Autoexec macro setup on a Access 2016 database to determine which form to open based on <code>Environ("USERNAME")</code>.</p>
  
  <p>When I open the database I get a macro Error 2001. If I click Stop All Macros, I can continue using the database without issue, until I change the filename, then the issue happens again.</p>
  
  <p>Are there any options to prevent this error from occurring?</p>
  
  <p>The code being called is</p>
  
  <pre><code>LUser = LCase(Environ("USERNAME")) 'Get current username
  
  DoCmd.OpenForm "frmDash", acNormal, , , , acWindowNormal
  
  If IsNull(DLookup("[sysname]", "tblaccmannew", "sysname=" &amp; "'" &amp; LUser &amp; "'")) Then
      DoCmd.OpenForm "frmSearch", acNormal, , , , acWindowNormal
      Forms!frmDash.Visible = False
  End If
  </code></pre>