title: How to resolve MS-Access Macro Error Number 2001?
body: <p>I have a copy of an Access database that is meant for importing discontinued product data from a .csv file into a SQL Server database (by using linked tables). When I initiate this import process, I get the following macro error:</p>
  
  <p><a href="https://i.stack.imgur.com/edg5E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/edg5E.png" alt="enter image description here"></a></p>
  
  <p>I looked up the 2001 Error Number and have seen a few different explanations of it. Mainly, that I need to add the location of the database as a trusted location. I have done that, but that hasn't made a difference.</p>
  
  <p>I noticed I can also see what code the problem occurs in, the "ImportDiscontinued()" function which looks like this:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Public Function ImportDiscontinued()
  Dim sImpSpec As String
  Dim sImpTable As String
  Dim sPath As String
  Dim sFile As String
  Dim db As Database
  Dim rsOption As Recordset
  Dim rs As Recordset
  
  Set db = CurrentDb
  Set rsOption = db.OpenRecordset("SELECT tblOptions.zValue FROM tblOptions WHERE (((tblOptions.zOption)='ImportPath'));")
      sPath = rsOption.Fields("zValue")
  Set rsOption = Nothing
  
  If Right(sPath, 1) &lt;&gt; "\" Then
      sPath = sPath &amp; "\"
  End If
  
  sImpSpec = "DiscontinuedItemMaster Import Specification"
  sImpTable = "tblDiscontinuedCurrent"
  sFile = sPath &amp; "DiscontinuedItemMaster.csv"
  
  DoCmd.SetWarnings False
  DoCmd.OpenQuery "dqDiscontinuedCurrent"
  DoCmd.OpenQuery "dqObsDiscontinuedDuplicates"
  DoCmd.TransferText acImportDelim, sImpSpec, sImpTable, sFile, True
  DoCmd.OpenQuery "dqDiscontinuedCurrent_Blanks"
  DoCmd.OpenQuery "uqObsDiscontinuedCurrent_SameProdRepl"
  DoCmd.OpenQuery "uqObsDiscontinuedCurrent_Trim"
  DoCmd.OpenQuery "uqObsDiscontinuedCurrent"
  DoCmd.OpenQuery "aqObsDiscontinuedDuplicates"
  DoCmd.SetWarnings True
  
  Set rs = db.OpenRecordset("dbo_tmpObsDiscontinued_Duplicates")
  
  If rs.EOF Then
      MsgBox "New Discontinued Items Have Imported Successfully! You may now process...", vbInformation + vbOKOnly, "Success!"
  Else
      MsgBox "Duplicates were found!. They will now be removed...", vbCritical + vbOKOnly, "Error"
      DoCmd.RunMacro "mcObsDiscontinuedDuplicates"
  End If
  
  Set rsOption = Nothing
  Set rs = Nothing
  
  db.Close
  
  End Function
  </code></pre>
  
  <p>But looking at it, I can't really see where things could be going wrong. I noticed I can set breakpoints, but they don't seem to get hit.</p>
  
  <p>I know that the connection to the SQL Server database is OK because I am initially prompted for credentials and then I am able to view the data through the linked table just fine.</p>
  
  <p>A disclaimer that I am only really familiar with the basics of Access so macros and coding in VBA is all new to me. I typically work with SQL Server databases and programming in C#.</p>
  
  <p>EDIT: Here is the macro "mcObsDiscontinuedImport":</p>
  
  <p><a href="https://i.stack.imgur.com/RYDPn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RYDPn.png" alt="enter image description here"></a></p>