Solved

Access 2003, my txt file export is running backwards

Posted on 2016-08-31
4
51 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

776 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