Solved

Transfer spreadsheet to SQL server cant append

Posted on 2006-07-18
6
690 Views
Last Modified: 2008-01-09
Hi all - Im using vba to programmatically transfer a spreadsheet to sql server, from vba code in my adp file.

i.e. docmd.transferspreadsheet acImport, acSpreadsheetTypeExcel10, tableMyTable, pathToFile,true

Because it doesnt correctly determine the data types, I figured I'd create the table first, then use this to append the data, as the help file explicity tells me that Data will be appended if the table exists or a table will be created if not.

However I get an error "Run Time error 3146, ODBC call failed, There is an already an object named 'mytablename' in the database(#(2714)"

Is there a way I can use transferspreadsheet to append to my table?

Thanks

0
Comment
Question by:valhallatech
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:infolurk
ID: 17136559
What you state above should be correct. If the table exists the data should be written to it.
However, for whatever reason, this isnt happening.
If the table doesn't exist, does the import work? If so you could check for the table's existence and if it is there delete it then run the import.
Im not familiar with adp files, does this mean you arent running the import from in access? Also, are you importing directly to an SQL table linked via ODBC? These things might be causing your problem.

cheers
Steve
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17136561
I wonder if this is specific to ADP's. Certainly with MDB, u can quite happily write and append to tables

This table of yours, its created on SQL Server and u linked it in right? I dont believe u can create local tables on ADP.

0
 
LVL 2

Author Comment

by:valhallatech
ID: 17136651
rockiroads: correct - the table is stored in sql server - yes I 'connected' to it - the linked concept as exists in an mdb file doesnt exist in adp files. yes the table is mine. As for am i going via odbc - i dont know - I connect using the  connect option on the file menu - which I thought used OLEDB, and that this was different to odbc - certainly I dont have to set up a dsn for eg. - im puzzled that the error quotes as being an ODBC error

infolurk: Yes this works as file/Import  in the menus system (actually it didnt work, it failed due to other reasons - but it didnt complain about existance of table). I dont want to be deleteing the the table if I can, as I create it for the purpose of actually determining the data type.  

0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 65

Expert Comment

by:rockiroads
ID: 17136689
Have u tried prefixing the tablename with the owner?
e.g.   dbo.mytablename

0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 17136700
Ive been reading this article, it seems to be a common problem
http://www.ureader.com/message/1323725.aspx

The workaround is to use ADO, open up the spreadsheet and read on row at a time
0
 
LVL 2

Author Comment

by:valhallatech
ID: 17136795

 have tried dbo

yeah - thought I'd try ado - in middle of giving it a go as we speak. god i hate access. seems to be working though.

I'll leave this open for a while longer to see if anyone can help me fix the problem 'properly' - and if nothing is forth coming give you the points for this.

Thanks for the link
Glenn
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question