export to text file

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

Hi

I have a macro that uses 'TransferText' to export data to a text file. In
the filename field is it possible to tell the macro to export to a file in
the same folder as the Access database. At the moment i have to specify a
full path which may not work if the database is moved. I have tried just
specifying a filename but this does not work.

Thanks in advance

Dan
 
This little function will return your path minus the database name:

Function DBPath() As String
Dim strDB As String
strDB = CurrentDb.Name
DBPath = Left(strDB, InStr(strDB, Dir(strDB)) - 1)
End Function

So you can use a statement like:

DoCmd.TransferText acExportDelim, "Standard Output", _
"External Report", DBPath() & "YourFile.txt"

--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top