Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-Time Error -2147352571
I have code that someone quite awhile ago helped me with that loads data from
an Excel spreadsheet into a SQL table and it works great. I have modified it for another worksheet on the same file and I am getting a 'run-time error -2147352571 (80020005) type mismatch' error and can not figure out what the problem is. If I click End and check the SQL Table, the data actually loads. If I click Debug, it stops at the line indicated below. I've gone back and forth on formatting and can't see anything. Does any one have any help for me? Thanks, Jani Here is the code: Sub ADOFromExcelToAccessProjectSpend() ' exports data from the active worksheet to a table in an Access database ' this procedure must be edited before use Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long ' connect to the Access database Set cn = New ADODB.Connection cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _ "Data Source=C:\DT\CARMGMT\CapitalExpenditure.mdb;" ' open a recordset Set rs = New ADODB.Recordset rs.Open "dbo_uCARProjectSpend", cn, adOpenKeyset, adLockOptimistic, adCmdTable ' all records in a table r = 3 ' the start row in the worksheet Do While Len(Range("A" & r).Formula) 0 ' repeat until first empty cell in column A With rs .AddNew ' create a new record ' add values to each field in the record .Fields("NumBudget") = Range("A" & r).Value .Fields("Alpha") = Range("B" & r).Value .Fields("Description") = Range("C" & r).Value .Fields("CapitalInvestment") = Range("D" & r).Value (if I click 'debug' this is the line highlighted) .Fields("StartUpExpense") = Range("E" & r).Value .Fields("CapitalOrSU") = Range("F" & r).Value etc., etc. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Run Time Error 1004: Application or Object Defined Error | Excel Programming | |||
Conditional Formatting - Run Time Error '13' Type Mismatch Error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming | |||
run-time error'-2147352571(8002005) | Excel Programming | |||
Run time Error -2147352571 when showing a form | Excel Programming |