Solved

Copy a table to a folder in Txt Format

Posted on 2013-01-25
9
235 Views
Last Modified: 2013-02-02
I need to copy a table to a folder.  The format will be in Txt Format.  VBA code with delimitors of commas.
0
Comment
Question by:Startrac98
  • 3
  • 3
  • 3
9 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 38818977
DoCmd.TransferText acExportDelim, , "Source Table or Query Name", "C:\folder\destination_file_name.txt"
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 38819101
you will need Export Specification to do that


1.right click on the table
2.select export > Text file
   click on Browse and locate the destination folder
3. (you can accept the proposed name or change it)
click Save, then click OK
4. In the export text wizard select the type (Delim Fixed) width
5. Follow the wizard, before clicking on Finish
     5a .Click Advanced
6. In the Export Specification dialog box Field Information List, correct any descrepancies

7. click save as, give the specification a name <-- this is the specification name that you will use in the command line below


DoCmd.TransferText acExportDelim, "ExportSpecName", "TableName", "C:\myCsv.csv", True
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38819137
Actually the above answer is not correct.   Export Specifications to enable the developer to define many properties of an export, but it is not a requirement to export a table or query to a file.

acExportDelim has as a default commas as delimeters.

So ... my answer is correct based on how the question was asked.
0
 

Author Comment

by:Startrac98
ID: 38830870
I have a concern with saving the specifications and using the Wizard.  If I want to copy the DB for other users to use on their PC's the saved specifications are not copied over.  That is why I think I have to write VBA code and not use the Wizard.  Unless there is a better way can you help with the VBA Code?  Thanks
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 119

Expert Comment

by:Rey Obrero
ID: 38830888
< If I want to copy the DB for other users to use on their PC's the saved specifications are not copied over.>

this is not true, the Specification are saved in an "Msys"  table and this table moves with the database.
0
 

Author Comment

by:Startrac98
ID: 38831116
ok, I'll check this out but I have had issues.  Is there any special settings or is this standard?
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 38831127
<Is there any special settings or is this standard? >
if you mean the "spec" saved in a table, YES this is standard
0
 

Author Closing Comment

by:Startrac98
ID: 38846488
This code worked fine and was very helpful.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38846868
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

747 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

18 Experts available now in Live!

Get 1:1 Help Now