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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button Event - export to txt file

Status
Not open for further replies.

atsea

Technical User
Feb 27, 2005
51
JP
It has been a while since I have used access...

All I need to do is export a file to a .txt file.

I've created a table with some values, and a simple form that has one button ("export").

Currently I'm trying to use: DoCmd.TransferText but I cant seem to get it to work. I cant remeber all of the parameters/elements that are involved. If someone could provide an example it would be greatly appreciated.

In addition, since there is and export function in access is there a DoCmd.export?

I would like to experiment with different methods of exporting from access into .txt files, it would be helpful if someone could direct me to some tutorials or provide some code examples.

Thanks in advance...

atsea
 
You have the TranserText, OutputTo methods that may apply (TransferSpreadsheet and TransferDatabase probably don't). In the help topics of them, are arguement list for them, and samples. (Hit F1 while the cursor is within the word in the VBE). Also a search in these fora with those as keywords, should give lots of samples.

You may want to take the time and read faq181-2886, which details how to get the most out of the membership. If your research doesn't help, have a look at #14 on how to get the best answers.

Roy-Vidar
 
I figured out how the .transfertext works...however it not only prints out the data in the file but the header as well...is there a way to print only the data? (without headers).

Here is the code for my export button:

Private Sub cmdExport_Click()

DoCmd.TransferText acExportDelim, "", "user IDs", "d:\export file.txt", True, ""

End Sub

Thanks,
 
In the VBA help for the TransferText method pay attention on the 5th argument.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV...you were axactly right, I just overlooked the fifth argument.

As for reading the VBA help...I guess I should mention next time that the version of acces I'm working in is Japanese and unfortunatley my ability to read japanese is limited. I try to get as much information off the net as possible, however I dont always have a reliable connection.

One more question regarding this matter...hopefully I just overlooked something again.

when I view the output in "export file.txt" everything appears alright except there is a blank line at the bottom.

Can this be removed? If so, how?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top