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

You are currently viewing the Access 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 7th, 2006, 02:22 PM
Authorized User
 
Join Date: Mar 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Insert Excel sheet content into Access table from

The subject just about explains my goal. From an access form, a button launches the following...

firstpath = "C:\class\orders.xls"

        Dim XL As Excel.Application
        Dim XLBook As Excel.Workbook
        Dim XLSheet As Excel.Worksheet

Set XL = CreateObject("Excel.Application")
    Set XLBook = GetObject(firstpathj)

    Set XLSheet = XLBook.Worksheets(1)


   DoCMD.RunSQL "INSERT INTO TABLE1 (VAR1, VAR1, ....)" & _
   "SELECT XLSheet.Cells(1,1), XLSheet.Cells(1,2) from XLSheet"


   I get the error
"MS Jet database engine could not find the input table or query XLSheet."

Does anyone know how to identify to access that xlsheet is the data source?


Thanks.




 
Old December 8th, 2006, 03:39 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I loaned out my book called "Integrating Excel and Access" published by O'Reilly, otherwise I would try to answer this. Look up the book if you are doing this sort of thing on a regular basis.

mmcdonal
 
Old December 8th, 2006, 04:18 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

There is a transferSpreadsheet function that might be useful here. I don't recall the exact syntax but it's a one line solution.

Hope that helps,

Mike

Mike
EchoVue.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
access to excel sheet conversion? ramniwas Visual Basic 2005 Basics 2 April 6th, 2008 08:38 AM
Importing Excel sheet into Access using ASP prasanta2expert ASP.NET 1.0 and 1.1 Basics 1 October 5th, 2006 02:36 PM
to save datagrid content to a excel sheet josna VB.NET 1 March 4th, 2006 07:10 AM
Update Access data from excel sheet Swift_PC Access VBA 1 October 20th, 2004 01:51 PM





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