Exporting to a text file

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

I have a query called qrylabels that is based on a table tblbospen. I want
to run the query from the Switchboard and also export the results from the
query to a comma separated text file called labels.txt. I know how to do
these procedures individually but I want it to be a seamless operation on
clicking a choice in the switchboard where the only intervention by the user
would be to ask them where to save the file. Can this be done using either a
macro or VBA? I'm a novice at VBA so please go gentle with me!
TIA
Tony Williams
 
Try something like:
sub TransText()
strFilePath = Inputbox ("Where do you want to save the file")
if strFilePath = "" then
exit sub
else
DoCmd.TransferText acExportDelim, ,"queryname", strFilePath
end if
End sub

HTH
 
Thanks Newbie that looks good
Tony
Newbie said:
Try something like:
sub TransText()
strFilePath = Inputbox ("Where do you want to save the file")
if strFilePath = "" then
exit sub
else
DoCmd.TransferText acExportDelim, ,"queryname", strFilePath
end if
End sub

HTH

either
 
Back
Top