Solved

Error during export thru VBA

Posted on 2006-11-29
3
288 Views
Last Modified: 2006-11-29
Hi: when i try to export data into textfile thru VBA it gives a message. But same thing if i go to the table and right click
and export there is no error. My question is why it gives me that error when i try to export thru VBA code?

Microsoft Access was unable to append all the data to the table.
The contents of fields in 1 record(s) were deleted, and 0 records were lost due to key violations. If data was deleted, the
data you pasted or imported doesn't match the field data type or the FieldSize property in the destination table.
If records were lost, either the records you pasted contain primary key values that already exist in the destination table,
or they violate referential integrity rules for relationship defined between tables.
Do you want to proceed any way?

DoCmd.TransferText acExportDelim, , "Qry_AlltblCustomersExport", "C:\MailSave\KDB_tblCustomers.txt"

Qry_AlltblCustomersExport
-------------------------
SELECT tblCustomers_Export.FormCode, tblCustomers_Export.Corp, tblCustomers_Export.House, tblCustomers_Export.Cust,
tblCustomers_Export.Name, tblCustomers_Export.Street, Left([CityStateZip],InStr([CityStateZip],",")-4) AS City,
Mid([CityStateZip],InStr([CityStateZip],",")-2,2) AS State, Trim(Mid([CityStateZip],InStr([CityStateZip],",")+1)) AS Zip
FROM tblCustomers_Export;

Thanks.
0
Comment
Question by:mustish1
  • 2
3 Comments
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18036782
M,
You should not get append errors with an export

DoCmd.TransferText acExportDelim, "", Qry_AlltblCustomersExport", "C:\MailSave\KDB_tblCustomers.txt", False, ""
0
 

Author Comment

by:mustish1
ID: 18036875
I try it but it gives same error
DoCmd.TransferText acExportDelim, "", "Qry_AlltblCustomersExport", "C:\MailSave\KDB_tblCustomers.txt", False, ""
0
 
LVL 34

Accepted Solution

by:
jefftwilley earned 500 total points
ID: 18036976
If the code you're using is part of a larger function, or series of them, then there is a problem somewhere else. You're not running an append query...yours is select.
If you step through the code, is the part you're pasting in where it fails?
J
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 Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

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

17 Experts available now in Live!

Get 1:1 Help Now