• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

ADODB.connection works for one workbook but not another

forwork

New Member
Hi,

Here's the background of the problem: I maintain an Excel data table with a new row for every new day. Many calculations are done with this data, which get presented monthly. The data also gets uploaded to an Access database each day using a 1-click button and VBA macro. The existing code for establishing a connection to the Access database looks like this:

Code:
' Define variables for connection, recordset, a counter, and the lastrow
Dim cn As ADODB.Connection, rs As ADODB.Recordset, i As Long, lastrow As Long
' connect to the Access database
Set cn = New ADODB.Connection
'define and open a recordset from the specified database path and database table name. Change it to suit your need.
cn.Open "Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=[path]\prices.accdb"
Set rs = New ADODB.Recordset
rs.Open "Prices", cn, adOpenKeyset, adLockOptimistic, adCmdTable

I'm creating an updated version of this table and the corresponding calculations and delivery. I would like to connect to the Database in the same way, and only update the method of selecting the data for upload (currently it uploads manually-selected data; I want it to upload the latest data automatically).

The problem is this: When I copy over the code for establishing a connection to the database as above, it does not work. I get the following error:
Run-time error '-2147467259 (80004005)':

[Microsoft][ODBC Microsoft Access Driver] General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x1314 Thread 0x1640 DBC 0x1e59fdc Jet'.

The upload to the Access db works from the old excel workbook, but not the new one, even with the exact same VBA code for establishing a connection.

Any help deciphering why this error occurs would be greatly appreciated!

forwork
 
Last edited:
I'd also make sure the first file is closed and even restart Excel again
 
Hi ,

Going by the number of results when this is put in Google , this seems to be a common problem , for which there does not seem to be a solution , since most of the links talk of changing the driver. Check these links :

http://board.issociate.de/thread/311110/Ugrade_from_4.01.3-max_to_4.0.16,_now_slower.html

http://www.justskins.com/forums/unable-to-open-registry-86102.html

However , this link says something different :

http://developer.earthskater.net/common_microsoft_access_errors.asp#FAQ2

Narayan
 
Hi all,

thanks for all the replies. Fortunately I figured out the issue over the weekend - the "DBQ=[path]" was incorrectly entered, such that it was trying to upload the data to a database in a protected folder. I'm not sure why this was the explicit error instead of a "restricted-access" type error, but it's now sorted out!

Thanks

forwork
 
Back
Top