Hey,
basically what I need to do is copy over some data (not much) from an excell sheet into a access table.
does anyone have any idea how to do this??
Here is the code I am using:
Dim objXL As Object
Dim xlWB As Object
Dim xlWS As Object
'some objects to refer to Excel
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim fld As DAO.Field
Dim x As Integer
'Just a counter
Set db = CurrentDb
Set rs = db.OpenRecordset("sampletable"
'open our recordset
Set objXL = CreateObject("Excel.Application"
Set xlWB = objXL.workbooks.Open("C:\adam\sample.xls"
Set xlWS = xlWB.worksheets("52"
'set references to our excel worksheet
'Set qd = db.TableDefs("sampletable"
'db.QueryDefs ("QrySelectDepartment"
'this is the manipulation with the excel table
With xlWS
.range("B2"
.select
For x = 0 To 2
rs.AddNew
rs(x) = .ActiveCell.Offset(0, x) 'IT DOESN"T LIKE THIS LINE
rs.Update
Next x
'move down a row on spreadsheet
End With
xlWB.Close
objXL.Close
Set xlWS = Nothing
Set xlWB = Nothing
Set objXL = Nothing
rs.Close
Set rs = Nothing
Set db = Nothing
'tidy up time
basically what I need to do is copy over some data (not much) from an excell sheet into a access table.
does anyone have any idea how to do this??
Here is the code I am using:
Dim objXL As Object
Dim xlWB As Object
Dim xlWS As Object
'some objects to refer to Excel
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim fld As DAO.Field
Dim x As Integer
'Just a counter
Set db = CurrentDb
Set rs = db.OpenRecordset("sampletable"
'open our recordset
Set objXL = CreateObject("Excel.Application"
Set xlWB = objXL.workbooks.Open("C:\adam\sample.xls"
Set xlWS = xlWB.worksheets("52"
'set references to our excel worksheet
'Set qd = db.TableDefs("sampletable"
'db.QueryDefs ("QrySelectDepartment"
'this is the manipulation with the excel table
With xlWS
.range("B2"
For x = 0 To 2
rs.AddNew
rs(x) = .ActiveCell.Offset(0, x) 'IT DOESN"T LIKE THIS LINE
rs.Update
Next x
'move down a row on spreadsheet
End With
xlWB.Close
objXL.Close
Set xlWS = Nothing
Set xlWB = Nothing
Set objXL = Nothing
rs.Close
Set rs = Nothing
Set db = Nothing
'tidy up time