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 March 14th, 2007, 02:04 PM
Registered User
 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can 'DoCmd.TransferSpreadsheet' do this?

Hi All,

I've only seen simple examples of 'DoCmd.TransferSpreadsheet', so I'm not sure if it can do want I'm trying to accomplish.

I have a directory of Excel workbooks, each with two sheets I need data from. One has the majority of the data I need (columns and columns of data) For the other, I just need the creators name and region from two cells.

I want to bring the main data into a table and then update the table last to fields with the name and region of the owner.

I've never used 'DoCmd.TransferSpreadsheet' and I haven't seen good examples how to use the range property to grab what I want. I figure sorting that out will get me the majority of my data. It's not working, but here's what I have:

Code:
Public Sub PopTb()
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "InfoSecTempTb", "I:\Planning and Technology\RCSA Analyzer\*.lxs", False, a3: ai46 , "Matrix-InfoSec$"
End Sub
For the other two fields I was thinking there must be a way to assign each one to a variable and run an update query, but then I'd have to run that update after every sheet import.

Is there a better way to do this? I thought maybe with ADOD functions, but I can't find anything on it. You ideas would be greatly appreciated.

Kind Regards, Travis


 
Old March 15th, 2007, 06:49 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Pull the other field range in as a new table, then take the values from the local table instead of the spreadsheet. You can create queries, or use ADO/DAO to run updates on the first table here.

Running the downstream queries or functions should not add much processing time.

Does that help any? Do you need more help with this?


mmcdonal
 
Old March 15th, 2007, 10:13 PM
Registered User
 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This helps, I just have one more question. My attached code doesn't seem to work. Can you tell me what's wrong with the syntax. I'm thinking it doesn't like the wildcard, but if you would happen to know it would save alot of guess and checking! Thanks for your help so far. T

 
Old March 16th, 2007, 04:07 AM
Registered User
 
Join Date: Oct 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have had a look at your code and it looks like you have the X & l the wrong way round. I presume you are looking at Excel sheets. should be xls not lxs

HTH

 
Old March 16th, 2007, 06:33 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Yeah, what he said.

mmcdonal
 
Old March 16th, 2007, 05:31 PM
Registered User
 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

*Argh* Stupid typo! Thanks guys, you rock!






Similar Threads
Thread Thread Starter Forum Replies Last Post
TransferSpreadsheet darkhalf Access VBA 2 February 15th, 2008 04:23 PM
TransferSpreadsheet stealthdevil Access VBA 2 March 16th, 2007 02:45 PM
ACCESS 2002 VBA DoCmd.TransferSpreadsheet joebob_houston Access VBA 3 March 7th, 2007 10:03 AM
TransferSpreadsheet kaleb0521 Access VBA 1 August 28th, 2006 12:59 PM
TransferSpreadsheet ajmil11 Access VBA 1 January 19th, 2006 02:07 AM





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