How to retrieve data from access database(.accdb) into excel using vba -


i'm working on excel vba macros , want retrieve data ms access database (.accdb file).

i've tried using below connection string , throws runtime error '438'

   dim cn object, rs object,dbfullname string,target range    dbfullname = "d:\tool_database\tool_database.accdb"    set target = sheets("sheet1").range("a1")    set cn = createobject("adodb.connection")    cn.open "provider=microsoft.ace.oledb.12.0; data source=" & dbfullname & ";"     set rs = createobject("adodb.recordset")    rs.open "select * test", cn, , , adcmdtext    int = 0 rs.fields.count - 1   target.offset(1, i).value = rs.fields(i).name   next   target.offset(1, 0).copyfromrecordset rs   rs.close   set rs = nothing   cn.close   set cn = nothing 

please me resolve error

i've tried using below connection string , throws runtime error '438'

run-time error: '438' means object doesn't support property or method..

you getting error because mixing vb.net vba

this

for int = 0 rs.fields.count - 1 

should be

for = 0 rs.fields.count - 1 

beside above, guess dbfullname = "d:\tool_database\tool_database.mdb" typo end using .accdb?


Comments