Hi,
I'm trying to get Excel 2007 to send some data to an existing table in Access, the amount of data can vary in size so needs to be dynamic.
code currently errors on the line Set rs = conn.OpenRecordset("ChannelGroupList", dbOpenTable)![]()
Sub DAOFromExcelToAccess() ' exports data from the active worksheet to a table in an Access database ' this procedure must be edited before use Dim r As Long Dim conn As New ADODB.Connection Dim sNWind As String Dim rs As Recordset sNWind = _ "C:\Documents and Settings\jonathan.broughton\Desktop\ChannelEconomics.accdb" conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & _ sNWind & ";" Set rs = conn.OpenRecordset("ChannelGroupList", dbOpenTable) r = 1 ' 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("Channel Group") = Range("A" & r).Value ' add more fields if necessary... .Update ' stores the new record End With r = r + 1 ' next row Loop conn.Close Set rs = Nothing End Sub
as this is wrong, but i need to be able to open the record at this location!
what am i doing wrong?
thanks
Jonathan
Bookmarks