Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export A Query 1

Status
Not open for further replies.

Ajwebb

MIS
Jul 31, 2003
153
GB
Hi All,

In Access 2000 when exporting a query it is possible to set up an Export Query Specification.

Is there anyway to export this query specification to a *.txt file through the use of a Macro or code for use from a command button, or can anyone point to any helpfull articles that will be of any use?

Thanks for any help

Ant

 
VBA code
look at docmd.TransferText method

DoCmd.TransferText acExportDelim, &quot;your saved spec name&quot;, &quot;your table name&quot;, &quot;a.txt&quot;, True '<< note true on the end is if you want field names as the first line.
Also you have to create an Export specification first and save it. Do this by right clicking on the table or query and clicking Export. Follow prompts when you see and &quot;advanced&quot; button at the lower left, click it and save the spec there.
&quot;REMEMBER&quot; the spec name or copy and paste it.
It goes in side quotes above in &quot;your saved spec name&quot;


DougP, MCP
 
Hi Doug,

I tried what you suggested and it seemed to work but then came up with an error:-

run-time error '3438':

The data being exported does not match the format described in the schema.ini file.

Any Ideas?

Thanks
 
Hi Doug,

Sorted now mate. In your sentence DoCmd.TransferText acExportDelim, &quot;your saved spec name&quot;, &quot;your table name&quot;, &quot;a.txt&quot;, True - I replaced &quot;Your Table Name&quot; with &quot;Query Name&quot; and it works fine.

Much appreciated.

Ant :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top