What is syntax to export a txt file from Access 2007 database

I wish to export a text file to disk from the results of a query

I am using the syntax:
DoCmd.TransferText acExportFixed, "Export-600-01 C Type", , "R:\Despatch\PBLink\600-01 C Type.TXT", False

This message appears:
Run-time error '2495':
The action or method requires a Table Name argument.

Where have I gone wrong?  Is there a better way?
Paul BurrowsAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
Try this with no Specification

DoCmd.TransferText acExportFixed, , "600-01 C Type", "R:\Despatch\PBLink\600-01 C Type.TXT"

and this is the general syntax:

DoCmd.TransferText(TransferType, SpecificationName, TableName, FileName

mx

0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:

DoCmd.TransferText acExportFixed, "Export-600-01 C Type", "YourTableNameHere" , "R:\Despatch\PBLink\600-01 C Type.TXT"

mx
0
 
raju1Commented:
Try this:
DoCmd.TransferText acExportDelim, "Standard Output", _
    "External Report", "R:\Despatch\PBLink\600-01-C-Type.TXT"
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Paul BurrowsAuthor Commented:
mx:  I am not sure whether I should be using the DoCmd.outputto command

raju1: I definitely want file to be fixed length - not delimited
0
 
Paul BurrowsAuthor Commented:
mx:  What could "YourTableNameHere" be?
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Well ... in your post:

DoCmd.TransferText acExportFixed, "Export-600-01 C Type",   , "R:\Despatch\PBLink\600-01 C Type.TXT",
       the table or query name goes between the two commas ^^^

mx                          
0
 
Paul BurrowsAuthor Commented:
As soon as I change line to read:

DoCmd.TransferText acExportFixed, "Export-600-01 C Type", "600-01 C Type", "R:\Despatch\PBLink\600-01 C Type.TXT"

The following message appears:

Run-time error '3625':
The text file specification 'Export-600-01 C Type' does not exist.  You
cannot import, export, or link using the specification.

This is the name used in the wizard - see screenshot
0
 
Paul BurrowsAuthor Commented:
Won't upload screen .... I don't know whats wrong now .... I just loaded explorer 8 so probably the latest security 'fix' from microsoft which stops everything working
0
 
Paul BurrowsAuthor Commented:
Run-time error '2511':
The action or method requires a Specification Name argument.


0
 
Paul BurrowsAuthor Commented:
DoCmd.TransferText acExportFixed, "600-01 C Type Export Specification", "600-01 C Type", "R:\Despatch\PBLink\600-01 C Type.TXT"

Thanks
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"Grade:  A - "DoCmd.TransferText acExportFixed, "600-01 C Type Export Specification", "600-01 C Type", "R:\Despatch\PBLink\600-01 C Type.TXT"

Thanks "

Always a pleasure Zarbs ...

mx
0
 
Paul BurrowsAuthor Commented:
mx

I'm always pleased you are about to prod me in the right direction.

I can go off happily to play squash without worrying about it

Cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.