+ Reply to Thread
Results 1 to 4 of 4

Access Stored Procedure Automation Error

  1. #1
    Registered User
    Join Date
    08-08-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    4

    Access Stored Procedure Automation Error

    Hi All

    I have a stored query procedure that executes fine in MS Access, but when I use the ADO library to execute said stored query procedure, and return the results to Excel, I receive an 'Automation error unspecified error -2147467259 (800004005)'.

    It appears to be when it tries to open the recordset (rst. open Source:=...etc), I've included both the VBA that calls the open procedure and the open recordset procedure code itself.

    Any help would be greatly appreciated.

    Cheers.

    Code:
    Please Login or Register  to view this content.
    Open recordset code:
    Please Login or Register  to view this content.
    Last edited by duftnich03; 01-16-2020 at 05:37 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Access Stored Procedure Automation Error

    Hello duftnich03,

    Unlike Access, Excel is not a RDB (Relational Database). Reading records in Excel can only be done sequentially. Your record set CursorType can only be 0 (adOpenForwardOnly) or 3 (adOpenStatic). Records in Excel are read only so the LockType must be 1 (adLockReadOnly). I have never used a stored procedure command in excel before. You may need to assign this to a string variable in your code and set the Options to 1 (adCmdText) instead of 4 (adCmdStoredProc).
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    08-08-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    4

    Re: Access Stored Procedure Automation Error

    Thanks for the info, but I use this approach in all of my Excel documents that refer to Access DBs and I have never had this issue before. As far as I understand it that LockType specifies what the Locktype in the DB is, not excel, as the code is passed to the Access DB engine.
    I have other queries that are run in the same way, in the same document, that use the same 'open_record_set' procedure as above with great success. I also have some that write back in other multi user environments and they don't work unless adLockOptimistic (3) is selected.

    I tried changing it to 1 at any rate, just confirm or deny my theory, and I does not work sadly.

  4. #4
    Registered User
    Join Date
    08-08-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    4

    Re: Access Stored Procedure Automation Error

    Right, I've solved it!

    The issue was in my SQL String:
    Please Login or Register  to view this content.
    The above runs fine in Access, but it doesn't when using the ADO libraries in VBA Excel.
    However the below does:
    Please Login or Register  to view this content.
    As you can see the only difference is I've put [] square brackets around my 'Size' field. So this would suggest that 'Size' is a reserved word in the ADO libraries and must be wrapped in [] square brackets when refering to a field name, yet it is not a reserved word in Access and therefore doesn't require the square brackets. This is why it worked in Access, but not in Excel.

    Thanks for the help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] ADO To Access SQL Stored Procedure Returning Error
    By NeedForExcel in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-07-2015, 07:40 AM
  2. SQL Stored Procedure From Excel
    By NeedForExcel in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 05-22-2015, 07:17 AM
  3. How to get stored procedure result in vba?
    By vvickyy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-11-2013, 01:38 AM
  4. Replies: 0
    Last Post: 10-02-2012, 03:06 PM
  5. Use SQL Stored Procedure
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-13-2011, 05:15 PM
  6. Automation error when opening Access database
    By GWB in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-26-2010, 05:04 PM
  7. stored procedure
    By qwertyjjj in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-17-2007, 01:02 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1