Another way to do this is to create a report with the correct formatting, then use the DoCmd.OutPutTo method to create a text file. This is handy if you want to do this routinely (although you could also just output the query, as suggested by jebry).