Solved

Access 2003, my txt file export is running backwards

Posted on 2016-08-31
4
35 Views
Last Modified: 2016-08-31
I am trying to export a table into a txt file, tab delim. I have the export spec built. When I run the code below, the existing data from the destination file gets inserted into the table. In other words, it's running completely backwards:

Private Sub cmdGetInventoryData_Click()

txtExportName = "C:\AmazonFeeds\data.txt"

DoCmd.TransferText acExportDelimited, "AmazonInventoryCreateData", "Data2", txtExportName

End Sub

Open in new window

0
Comment
Question by:QMBB
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:TechieMD
ID: 41778933
I believe acExportDelimited isn't a valid TransferType, and as such, is reverting to the default of acImportDelim.

Try acExportDelim instead of acExportDelimited:

Private Sub cmdGetInventoryData_Click()

txtExportName = "C:\AmazonFeeds\data.txt"

DoCmd.TransferText acExportDelim, "AmazonInventoryCreateData", "Data2", txtExportName

End Sub

Open in new window

0
 

Author Comment

by:QMBB
ID: 41778944
Derp. That was it.

BUT I found another problem... the exported data does not include the field names, and I need it to. I double checked the Saved Spec, even recreated it making sure the box was checked, but the written output is only showing me the records. Ideas?
0
 
LVL 5

Accepted Solution

by:
TechieMD earned 500 total points
ID: 41778954
For that, we just add True for the next parameter (which is HasFieldNames):
Private Sub cmdGetInventoryData_Click()

txtExportName = "C:\AmazonFeeds\data.txt"

DoCmd.TransferText acExportDelim, "AmazonInventoryCreateData", "Data2", txtExportName, True

End Sub

Open in new window

0
 

Author Comment

by:QMBB
ID: 41778957
Niiiice... thanks much.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

762 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