PDA

View Full Version : Export Table To Csv File By Date



jmentor
11-20-2014, 08:16 AM
What I would like to achieve via code on a button
From the table orders


orderDate orderID ref name amt vat
----------------------------------------------
02/02/2014 56789 01 magdi 600 100
22/06/2014 12122 01 magdi 654 100
22/06/2014 65897 02 simon 250 159
22/06/2014 12345 02 simon 156 140
23/07/2014 56781 01 magdi 400 250
01/08/2014 12457 01 magdi 250 900
01/09/2014 56787 02 simon 126 500
02/09/2014 56781 04 peter 400 250
02/09/2014 12345 02 simon 450 122
02/09/2014 65897 04 peter 250 231
02/09/2014 12122 05 hargr 654 100
02/09/2014 79457 05 hargr 254 200



I need to export to csv files from the above based on unique date and
ref fields and with filename showing date and ref. So from the above we
should get 9 csv files in this format

02/02/2014-01.csv
22/06/2014-01.csv
22/06/2014-02.csv
23/07/2014-01.csv
01/08/2014-01.csv
01/09/2014-02.csv
02/09/2014-02.csv
02/09/2014-04.csv
02/09/2014-05.csv

Some help on how to produce the above result greatly appreciated

jonh
11-20-2014, 10:12 AM
Group the date and ref fields in one query to get the filters for a second query which you then output the data from. Somthing like Docmd.transfer text I think.