Chat with a LIVE Microsoft Access Expert!
 
       
 

         

   

Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
 
Chat with a LIVE Microsoft Access Expert!
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-12-2006, 04:40 AM
itchyII itchyII is offline
Registered User
 
Join Date: Sep 2006
Posts: 2
itchyII is on a distinguished road
TransferSpreadsheet for import, Error 3011

Hello All,
This is my first time on this forum. I have a function that I use to import data from Excel spreadsheets. I have used this code before without problems. The only thing different with this import is that the data I want to import is in non adjacent columns. Here is the code:

Function importMatspc(UploadFile As String) As Boolean
'----------------------------------------------------------------------------
'
' Function: importMatspc
'
' Description: Imports columns from the Matspc Excel file
'
' Arguments: UploadFile - the file selected for upload (should be the matspc
' file updated daily)
'
' Returns: True if successful
' False if failed
'
'-----------------------------------------------------------------------------

Dim filename As String
Dim fs
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim flag As Boolean

flag = False

Set fs = CreateObject("Scripting.FileSystemObject")

filename = UploadFile

If Not fs.FileExists(filename) Then
GoTo noFile
Else
'Purge Results table
Set cnn = CurrentProject.Connection
Set cmd = New ADODB.Command
cmd.ActiveConnection = cnn
cmd.CommandText = "DELETE * FROM Results"
cmd.Execute

'load data from excel file
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "Results", filename, vbYes, "Results!B:B,L:L,P:P,R:R,AA:AA"

GoTo fileImported
End If


noFile:
flag = False
GoTo cleanup

fileImported:
flag = True

cleanup:
Set fs = Nothing
Set cnn = Nothing
Set cmd = Nothing
importMatspc = flag

End Function

and here is the error I am getting:

"Run-time error '3011'

The Microsoft Jet Database engine could not find the object 'Results$B:B,L:L,P:P,R:R,AA:AA'. Make sure the object exists and that you spell its name and the path name correctly."


First I thought it might be something with the file name, so I shortened it, but it still didn't work. Then I tried naming the range in Excel and specifying the named range in my transferspreadsheet command, but it gave me the same error. Can anyone see what is going on? The spreadsheet contains about 55000 rows, could that be a problem?

Any help is appreciated!

Thanks!
Reply With Quote
Sponsored Links
  #2  
Old 09-13-2006, 10:07 AM
Timtropolis Timtropolis is offline
Registered User
 
Join Date: Jun 2004
Location: Sopranos land
Posts: 67
Timtropolis is on a distinguished road
Hi Itchy,

Shot in the dark here, but what version of office are you using? If its 2003,
try changing your acSpreadsheetTypeExcel8 ref in the transferspreadsheet to acSpreadsheetTypeExcel9. I had an issue a while back with row counts in office2003 due to acSpreadsheetTypeExcel defaulting to the wrong version and making this change fixed it.

HTH,
Tim
Reply With Quote
  #3  
Old 09-13-2006, 10:24 AM
boblarson's Avatar
boblarson boblarson is online now
Super Moderator
 
Join Date: Jan 2001
Posts: 22,002
boblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to allboblarson is a name known to all
Excel Version 9 - Office 2000
Excel Version 10 - Office 2002 (XP)
Excel Version 11 - Office 2003
__________________
Thanks,

Bob Larson

Free samples, tools and tutorials (including Auto Frontend Update Enabling Tool)

"Have you tried turning it off and on again?"
Reply With Quote
  #4  
Old 09-14-2006, 05:10 AM
itchyII itchyII is offline
Registered User
 
Join Date: Sep 2006
Posts: 2
itchyII is on a distinguished road
Thanks!

I am using 2003, will try changing the reference. In the mean time, I found a work-around using another data source...
Reply With Quote
Sponsored Links
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
TransferSpreadsheet with Named Range eschaef2 Modules & VBA 3 12-08-2008 01:24 AM
TransferSpreadsheet not "releasing" the file rglman Modules & VBA 1 09-27-2005 05:59 AM
Transferspreadsheet susanmgarrett Macros 3 06-09-2005 10:13 AM
TransferSpreadSheet w/filtering?? SpongeBob Modules & VBA 1 06-03-2003 08:20 AM
opening excel after transferSpreadsheet shaggyjb Modules & VBA 2 11-15-2002 05:14 AM


All times are GMT -8. The time now is 09:49 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) copyright 2009 Access World