Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's my code. I'm pulling my hair out trying to get this to work. Thanks.
Sub ExcelToAccess() Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long Set cn = New ADODB.Connection cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=E:\Databases\CostTracking.mdb;" Set rs = New ADODB.Recordset rs.Open "TotalCostSummary", cn, adOpenKeyset, adLockOptimistic, adCmdTable r = 2 Do While Len(Range("A" & r).Formula) 0 With rs .AddNew .Fields("Quote") = Range("A" & r).Value .Fields("Job") = Range("B" & r).Value 'multiple fields follow these two .Update End With r = r + 1 Loop rs.Close Set rs = Nothing cn.Close Set cn = Nothing End Sub "Chip Pearson" wrote: Now I get "Application-defined or object defined error" That error message, typically with error number 1004, is Excel/VBA's way of telling you the *something* went wrong without shedding any light on *what* went wrong. Without seeing the code that is causing the error, it is impossible to diagnose and provide a fix for the problem. -- Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2008 Pearson Software Consulting, LLC www.cpearson.com (email on web site) "dmac" .(donotspam) wrote in message ... I have it checked, now, thanks for the help. I'm still having other problems now. I'm a little over my head. Now I get "Application-defined or object defined error" Any thoughts? "Chip Pearson" wrote: I get a compile error, "User defined type not defined" and it highlights cn As ADODB.Connection You'll get that if you don't have the ADO library selected in the References (Tools menu, References). -- Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2008 Pearson Software Consulting, LLC www.cpearson.com (email on web site) "dmac" .(donotspam) wrote in message ... I get a compile error, "User defined type not defined" and it highlights cn As ADODB.Connection Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
run time error 1004 general odbc error excel 2003 vba | Excel Programming | |||
Run Time 1004 Error: Application or Object Difine Error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming | |||
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error | Excel Programming | |||
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) | Excel Programming |