ODBC Call Failed - Error 3151 RRS feed

  • Question

  • We have an Access database migrated from Access 97 to Acces 2007 with some linked tables to an SQL Server 2008 database. We are using a File DSN in the ODBC Administrator. Connection tests work fine there. In fact, we have a main form in the Access 2007 application that shows the data always correctly. The problem appears when we execute a task that makes the following call:

    Dim dbs As Database
    Dim rstAppend As Recordset
    Set dbs = CurrentDb
    Set rstAppend = dbs.OpenRecordset(strAccessTable, dbOpenDynaset, dbSeeChanges)

    OpenRecordset throws the error number  3151 and occurs randomly but it appears quite frequently.  It's sporadic. When we don't get the error, the task works fine.

    1. It not happens always, mosty we're fine.
    2. When it happens it happens for all subsequent tasks tried. We have to close and reopen the Access database and pray to the good Lord that it works.
    3. <Sometimes, refreshing the tables in the Linked Table Manager solves the problem, but others don't.  
    4. We receive  sometimes an error "ODBC--Call Failed" when refreshing  the Linked Table Manager. Deleting the File DSN and creating a new one solves the problem.
    5. We have tried with two different drivers (SQL Server and SQL Server Native Client 10) and in both cases the problem remains.
    6. Also we have tried to put the Access File in the same machine than the SQL Server and the problem remains.

    We would be very happy if someone could help us to find a solution to this problem.

    • Moved by KJian_ Monday, September 27, 2010 7:21 AM (From:SQL Server Data Access)
    Friday, September 24, 2010 8:58 AM

All replies

  • Hello rodpedja,

    Unfortunately, error 3151 is a fairly generic error that indicates that an ODBC connection failed.  We have seen in some previous cases that this can be caused by a networking issue, or by external applications as well.  One of the first things I would want to know here is whether the problem still occurs if you boot your computer using Safe Mode with networking.  This should help us eliminate outside interference.

    When you say that your executing a task, what does that mean?  I see that your using DAO to open a recordset, but I'm trying to understand the larger picture.

    Best Regards,
    Nathan Ost
    Microsoft Online Community Support

    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Tuesday, September 28, 2010 8:53 PM
  • Hi,


    I'm getting the exact same thing.  Access 2007 DB, linked tables.  Can even go so far as to have a form linked to a table open and happily using data from linked table, but if you try to use the same table programmatically (almost identical code to above) it fails probably about 60% of the time with error 3151.

    It's not very helpful for Microsoft to have these big, generic error codes.  It would be more helpful if it could be pinpointed to a networking glich, or if that could be alleviated.  Surely that shouldn't be difficult?  They must know wether it's the transport that wasn't fulfilled, or the engine that rejected the call, or the table that couldn't be accessed or whatever?

    Stumped with this now.  Am currently trying out ADO to see if it's moe reliable than the built-in DAO.

    Thursday, October 7, 2010 11:12 AM
  • Hi,

    I faced the same error trying to run system stored procedures via pass-throgh queries. What's interesting, if it is sp_adduser it works fine, but if it is sp_droprole or sp_dropuser - this error appears. The same situation with CREATE USER SQL statement (works fine) and DROP USER (this error appears).

    Andrey V Artemyev | Saint-Petersburg, Russia
    Thursday, October 7, 2010 11:18 AM
  • This is a fairly generic error message, so the cause of it may be a bit different for each situation.  You could take a look at KB 209855 to see if this helps with providing a more detailed error message for your specific situation.

    209855 ACC2000: How to Trap Specific ODBC Error Messages;EN-US;209855

    Best Regards,
    Nathan Ost
    Microsoft Online Community Support

    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Friday, October 8, 2010 8:59 PM
  • Hi All,

    so I had same problem with my Conection with Access database. 

    My Access quries are based on SQL linked tables,  those queries are then linked to Excel datamodel (as pivot table)
    Im was getting this error when trying to refresh Excel data model. 
    I was really frustrated as in Access all queries were refreshing properly and then ...


    Problem started to appear when I was expanding the queries with the new linked tables, so I started to delete the tables one by one to discover which one is causing the errro , and then I realized that I was importing (linking to SQL acutally) the tables without saving the password. Erorr disapeard when I have imported all the tables once again with password do SQL saved in DSN file (and within access) 

    the problem appeard once again recetly, I realized that i have copied the existing tables intead of importing them 2nd time. 

    So the key to this problem was the missing password in the SQL linked tables. 

    good luck : )

    • Edited by bybros Wednesday, April 12, 2017 11:05 AM
    Wednesday, April 12, 2017 11:05 AM
  • Hi All

    I realize this is a very old post. I found this page when looking up possible reasons for the 3151 error. I have a complex Access program that was created by a company that has since closed. The PC it's on crashed but I had a backup of the files. When I tried to run it on a different PC I got the error. 

    I managed to find which DSN it was trying to reference and I set that up in ODBC. To find the DSN name I went to External Data and looked under the Linked Table Manager.

    Once the correct DSN was set up the program worked 100%

    Hope this helps someone in the future
    Thursday, May 2, 2019 11:49 AM