Solved

Transfer spreadsheet to SQL server cant append

Posted on 2006-07-18
6
683 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
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
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…
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.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

760 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

20 Experts available now in Live!

Get 1:1 Help Now