in Education by
I'm working on Excel VBA macros and I want to retrieve data from a MS Access database (.accdb file). I've tried using below connection string and it throws runtime error '438' Dim cn As Object, rs As Object,DBFullName As String,Target As 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 * FROM test", cn, , , adCmdText For int i = 0 To 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 help me to resolve the error JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I've tried using below connection string and it throws runtime error '438' Run-time error: '438' means that the Object doesn't support this property or method.. You are getting that error because you are mixing VB.Net with VBA This For int i = 0 To rs.Fields.Count - 1 should be For i = 0 To rs.Fields.Count - 1 Beside the above, I guess DBFullName = "D:\Tool_Database\Tool_Database.mdb" is a typo from your end as you are using .Accdb?

Related questions

0 votes
    I have 7 excel sheets in one workbook and I am trying to copy and paste the data from each excel ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I have set up a new, empty, modeless userform, to fix my problem with the least amount of code ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I am using Excel where certain fields are allowed for user input and other cells are to be protected. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 18, 2022 in Education by JackTerrance
0 votes
    I am using Excel where certain fields are allowed for user input and other cells are to be protected. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    This question is corresponding to this link VBA Excel : Extract data in specific format from CSV files but ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    What are some of the Excel VBA functions commonly used?...
asked Oct 19, 2020 in Technology by JackTerrance
0 votes
    How could we retrieve a single value from data base using Groovy?...
asked Sep 25, 2021 in Technology by JackTerrance
0 votes
    Is there any way to change the default datatype when importing an Excel file into Access? (I'm using ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    Is there any way to change the default datatype when importing an Excel file into Access? (I'm using ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    Is there any way to change the default datatype when importing an Excel file into Access? (I'm using ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    Is there any way to change the default datatype when importing an Excel file into Access? (I'm using ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    what i want : i have a config file where it contains some urls in .json file stored in asset ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    While I'm developing my MS Access application, I open it with shift click. When an Error occurs, ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I am looking for a free tool to load Excel data sheet into an Oracle database. I tried the Oracle ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 22, 2022 in Education by JackTerrance
...