excel - VBA - provider cannot be found with accdb format -


with below code following error when ran provider cannot found, below code copied , edited net, used .mdb files tried change .accdb because thats format need in. i'm trying make macro when ran copies cells database, adding it.

i error

 run-time error "3706"  provider cannot found may not installed 

-

const target_db = "testdb.accdb"  sub alteronerecord()    dim cnn adodb.connection    dim rst adodb.recordset    dim fld adodb.field    dim myconn    dim lngrow long    dim lngid string    dim j long    dim ssql string     'determine id of current record , define sql statement    lngrow = activecell.row    lngid = cells(lngrow, 1).value     ssql = "select * tblpopulation popid = " & lngid     set cnn = new adodb.connection    myconn = thisworkbook.path & application.pathseparator & target_db     cnn      .provider = "provider=microsoft.ace.oledb.12.0;"      .open myconn    end     set rst = new adodb.recordset    rst.cursorlocation = aduseserver    rst.open source:=ssql, _             activeconnection:=cnn, _             cursortype:=adopenkeyset, _             locktype:=adlockoptimistic     'load contents of modified record excel access.    'do not load id again.    j = 2 7       rst(cells(1, j).value) = cells(lngrow, j).value    next j    rst.update     ' close connection    rst.close    cnn.close    set rst = nothing    set cnn = nothing end sub 

is there easier way this? or should try , fix this?

what missing complete connection string data base file.

(more connection string)

i give rough idea works code:

remove line in code:

.provider = "provider=microsoft.ace.oledb.12.0;"

instead use one:

.connectionstring= "provider=microsoft.ace.oledb.12.0;" 

or use 1 instead:

.provider = "microsoft.ace.oledb.12.0"     

for further information see this w3schools website.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -