Export query to a tab delimited text file

Swifey

Active Member
Joined
Jan 16, 2003
Messages
421
Could you please help? I am wanting to automatically export a query as a Tab Delimited Txt file.
But when I write a macro to export the query it exports it in the wrong format.

For example my following code


DoCmd.OutputTo cQuery, "Q_PostSector", "MS-DOSText(*.txt)", "\\cmq0059\\Customer Relationship Management\Customer\Data\Post Sector.txt", False, "", 0 exports the file in the following format
---------------------------------------------------------------
salesoffice | reparea | customerno |
---------------------------------------------------------------
2 | 3 | 12 |
----------------------------------------------------------------

But when I exported file manually through the wizard I get following format

"URN" "customer" "name" "rank"
"10/05" "05" " Ltd " "0"

Kinds Regards
[/code]
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Use the TransferText method instead, with the acExportDelim TransferType. Post back if you need more details.

-Russell
 
Upvote 0
Hi - I tried the following code, but it dosnt recognise my query I want to export to a shared directory.

Code:
DoCmd.TransferText acExportDelim, "Q_PostSector", "MS-DOSText(*.txt)", "\\cmq0059\\Customer Relationship Management\Customer\Data\Post Sector.txt", False, "", 0

Kind regards
 
Upvote 0
Check Help for how TransferText is used. I don't think you need the MS-DOS part. Just try something like:
Code:
DoCmd.TransferText acExportDelim, , "Q_PostSector", "\\cmq0059\\Customer Relationship Management\Customer\Data\Post Sector.txt", True
Hope this helps,
Russell
 
Upvote 0

Forum statistics

Threads
1,221,680
Messages
6,161,251
Members
451,692
Latest member
jmaskin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top