Print # to text file

rbs

Board Regular
Joined
Oct 6, 2002
Messages
58
Hi Everyone,

I have a query that through a module, I wish to use the print # command. to write to a text file.

Can anyone help as to how I get the module to write all lines of the query to the text file?

Thanks in advance,


Natalie.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
You will need to loop through your record set adding 1 record at a time to the text file. Write# is usually better for writing text files that you may want to use as data sources.

You could also create a query and use the TransferText method to create the text file, which could be easier/faster.
Code:
    Set qdf = MyDb.CreateQueryDef("tempTest", strSQL)
    DoCmd.TransferText acExportDelim, , "tempTest", "C:\test.txt"
    DoCmd.DeleteObject acQuery, "tempTest"

HTH

Peter
 
Upvote 0
Thanks for your help.

I can't transfer the query in this way because I am saving the file as a dat file and it will not let me use this file extension.

I also don't want any delimiters in the file.

Any Advice

Thanks,

Natalie
 
Upvote 0

Forum statistics

Threads
1,221,567
Messages
6,160,540
Members
451,655
Latest member
rugubara

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