Solved

Access 2003, my txt file export is running backwards

Posted on 2016-08-31
4
58 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
[X]
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
  • 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

738 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