Prev Previous Post   Next Post Next
  #1   Report Post  
keithl816
 
Posts: n/a
Default Excel to access


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
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
How do I a cell in Excel to a cell in Access? maacmaac Excel Discussion (Misc queries) 1 September 8th 05 04:39 AM
Microsoft Access Report into Excel Spreadsheet zeebyrd Excel Discussion (Misc queries) 1 February 27th 05 12:36 AM
How do I get an Access form in Excel to Expand the Data RogerN Excel Discussion (Misc queries) 0 February 25th 05 06:04 PM
Linking Excel to Access. Richard Excel Discussion (Misc queries) 3 February 15th 05 09:55 PM
Managing an Access Database from Excel Kostis Vezeridis Excel Discussion (Misc queries) 2 February 11th 05 05:21 PM


All times are GMT +1. The time now is 03:08 PM.

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

About Us

"It's about Microsoft Excel"