Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 13th, 2007, 01:25 PM
Authorized User
 
Join Date: Jun 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Transfer data from Excel to Access


I have this code below, which uses DAO to automatically transfer data from Excel to Access.

Can someone explain what the difference is from DAO and ADO? If I was to do the same project using ADO how could I do this? and the other issue is that the users that will be using the Excel report will not have MS Access installed on there PC. Does this change the way the code has to be written?

Sub AddToMDB()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim r As Long

Set db = DAO.DBEngine.OpenDatabase("D:\Work\MILtd.mdb")
Set rs = db.OpenRecordset("tblExcelImport", dbOpenDynaset)
r = 2
Do While Len(Range("A" & r).Formula) > 0

rs.AddNew
rs![Day of Week] = Range("A" & r).Value
rs!WeekNum = Range("B" & r).Value
rs!Week = Range("C" & r).Value
rs!ConcatDate = Range("D" & r).Value
rs![HEAT - BCC] = Range("E" & r).Value
rs![HEAT - Leeds] = Range("F" & r).Value
rs![JD Heating] = Range("G" & r).Value
rs![RG Francis] = Range("H" & r).Value
rs!TotalDay = Range("I" & r).Value
rs![Weekend?] = Range("J" & r).Value
rs!User = "Jez L"
rs.Update

r = r + 1
Loop
Set db = Nothing
Set rs = Nothing

End Sub


Thanks,
Jez







Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfer Dynamic Data from Excel to Access DB ? poorheler Excel VBA 2 July 2nd, 2007 11:11 AM
Data transfer from Access to Excel swaroop Access VBA 2 June 1st, 2007 10:30 AM
how to transfer data from excel to Access database swaroop Access VBA 5 April 13th, 2007 09:02 AM
how to transfer data from excel to Access database swaroop Excel VBA 1 April 12th, 2007 10:45 AM
Transfer Data to Excel one cell at a time mahulda ASP.NET 1.0 and 1.1 Basics 2 April 28th, 2004 04:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.