Solved

Transfer spreadsheet to SQL server cant append

Posted on 2006-07-18
6
687 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now