Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Conditional Formatting - Run Time Error '13' Type Mismatch Error ksp Excel Programming 0 July 11th 06 07:06 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
run-time error'-2147352571(8002005) cfii Excel Programming 2 April 20th 05 03:06 AM
Run time Error -2147352571 when showing a form Ric Payne Excel Programming 2 October 2nd 03 04:48 AM


All times are GMT +1. The time now is 11:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"