Link to home
Start Free TrialLog in
Avatar of Paul Burrows
Paul BurrowsFlag for New Zealand

asked on

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?
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image


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

mx
Avatar of raju1
raju1

Try this:
DoCmd.TransferText acExportDelim, "Standard Output", _
    "External Report", "R:\Despatch\PBLink\600-01-C-Type.TXT"
Avatar of Paul Burrows

ASKER

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
mx:  What could "YourTableNameHere" be?
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                          
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
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
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Run-time error '2511':
The action or method requires a Specification Name argument.


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

Thanks
"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
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