Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Transfer spreadsheet to SQL server cant append

Posted on 2006-07-18
6
694 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do you delete the header in a text file with VBA 5 30
SQL Select in Access 2003 3 25
Access/Visual Basic Question 3 24
Importing Excel file into Access 5 26
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

860 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