Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]() Hello everybody, I hope someone can help me with this problem, I got the code below from this website. http://www.erlandsendata.no/english/...php?t=envbadac I'm trying to send data to an access table already created in a access db. I followed the instructions on this site and still can't seem to make it work. Where am I supposed to place this code? I tried right clicking the sheet tab in excel and placing it in the sheet code that the info is appearing on but it did not work. I also tried placing it in a module. Still doesn't work. Code: -------------------- Sub ADOFromExcelToAccess() 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=C:\monthly report\boomaxedb.mdb;" Set rs = New ADODB.Recordset rs.Open "boomaxedb", cn, adOpenKeyset, adLockOptimistic, adCmdTable r = 3 ' the start row in the worksheet Do While Len(Range("A" & r).Formula) 0 .AddNew .Fields("date") = Range("A" & r).Value .Fields("operator") = Range("B" & r).Value .Fields("name of road") = Range("C" & r).Value .Fields("distance") = Range("d" & r).Value .Update End With r = r + 1 ' next row Loop rs.Close Set rs = Nothing cn.Close Set cn = Nothing End Sub -------------------- The data is stored in excel workbook named monthly report it is located in a folder named Monthly, the access table is named boomaxedb. it is located in the same folder. I also clicked on the tools in vbe and reference and checked the box next to microsoft activexdata objects 2.6 library. Thanks in advance, Larry -- keithl816 ------------------------------------------------------------------------ keithl816's Profile: http://www.excelforum.com/member.php...o&userid=21287 View this thread: http://www.excelforum.com/showthread...hreadid=472278 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I a cell in Excel to a cell in Access? | Excel Discussion (Misc queries) | |||
Microsoft Access Report into Excel Spreadsheet | Excel Discussion (Misc queries) | |||
How do I get an Access form in Excel to Expand the Data | Excel Discussion (Misc queries) | |||
Linking Excel to Access. | Excel Discussion (Misc queries) | |||
Managing an Access Database from Excel | Excel Discussion (Misc queries) |