Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export Table To Csv File By Date

Status
Not open for further replies.

jmentor

Technical User
Nov 20, 2014
2
GB
What I would like to achieve via code on a button
From the table orders


Code:
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


Go Back Access World Forums > Microsoft Access Discussion > Modules & VBA
Reload this Page Export Table To Csv File By Date
User Name Remember Me?
Password


Register FAQ Community Top Posters Today's Posts Search



Community Links
Social Groups
Pictures & Albums
Members List
Calendar

Search Forums


Show Threads Show Posts
Tag Search
Advanced Search
Find All Thanked Posts

Go to Page...





Reply
Thread Tools Rate Thread Display Modes

Old Today, 06:48 AM #1
jmeek
Newly Registered User


Join Date: Aug 2005
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
jmeek is on a distinguished road Export Table To Csv File By Date

--------------------------------------------------------------------------------

What I would like to achieve via code on a button
From the table orders


Code:
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 200I need to create csv files from the above based on unique date and
ref 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
Please see attached zip file so you can see what I have achieved
so far



 
Hi,

Welcome to Tek Tips.

You've posted a whole lot of information that seems to be irrelevant. There was no ZIP file. The task seems a bit questionable.

Perhaps you could state the reason for chopping up your data into so many .csv files.
 
apologies about that

I am sure I attached the zip file.
will try and attach and send again

I also noticed a lot of text which I certainly
did not include in the post. Do not know from
where all the rubbish came from

It may be because this is my first post that
things are not registering properly

The link

I just tested the link and it seems to be working

To answer your question. I need to export to multiple csv files a very large table. Export to be based on
date and ref. You will get a better idea when you have seen the mdb file
Hope you can help. If not clear, please ask me
 
Create a recordset based on the SQL:
[tt]
Select *
From Orders
Order By orderDate, ref
[/tt]
Loop down the rst and create CSV file named: [tt]
Format(rst!orderDate, "dd/mm/yyyy") & rst!ref & ".csv"[/tt]
every time orderDate or ref changes.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top