Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Extract table data into separate files...

Extract table data into separate files...

Extract table data into separate files...

I have a table of approx. 5000 records.  Each sales unit has between 1 and 25 records unique to it.  The first field in the table is the ID No. which identifies one unit from another.

I need to extract each unit's data (whether it's 1 record or 25) from the main table and create a separate text file or xls file for each unit.

This operation would be performed each week and each unit's total number of records would differ from week to week.

Any suggestions?  Thanks.


RE: Extract table data into separate files...

I see two ways to accomplish this and the way you choose all depends on how comfortable you are with VBA coding.   

1.   Write a function that would loop through the table 25 times (one recordset for each department), writing the data to a file.   You might be able to do it in one large loop, but I don't know about any limitations on opening and writing to 25 different data files at one time.   This would require you being very comfortable with VBA.

2.   Create 25 SQL make table queries to dump each department into a temporary table.   Then create a function with 25 TransferText function calls.

There is probably a better idea out there somewhere.   I think either way will be a bit tedious, at least until you have it set up.

Hope that helps..

Terry M. Hoey
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close