Results 1 to 5 of 5
  1. #1
    broecher is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Sep 2010
    Posts
    38

    export a series of csvfiles

    I would like to learn how to automate some exporting. Right now I have a 'query1' that varies from 10-20 records. Each of these records needs a separate csv file exported for it. The csv is based on this other 'query2', but I have to go into query2 and change the criteria for each of these 10-20 records. and repeat the export after changing the criteria each time.

    I started by attempting to build a macro. I have been able to figure out how to make the macro export a single csv for me after I manually change the criteria for each item, but that's all.

    I am a total newbie so I am not sure how difficult this might be. I don't know any vba yet.

    I would like to run query2 once for each the criteria from a field in query1, and have a csv exported for each one that has a file name based on the items from query1

    Example:
    Query1 contains a field called ID and it lists f1,f3,f22.....

    Querry2 has the same ID field but it is filtered for only one of the ID's at a time (criteria: "f1")

    I would like export query2 into f1.csv f3.csv f22.csv .....




    Maybe it would be easier if someone could just tell me what the different syntax that I need to learn is, can I do this in macro or do I have to do something else... That type of info would be great for a start.

    Thanks
    Last edited by broecher; 09-10-2010 at 07:26 PM. Reason: additional request

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    producing an automated method to produce a variable quantity (10 to 20) of exports isn't a trivial task. So as a self described novice without vba don't feel bad if it seems complicated.

    because the quantity is variable - you need a method to first determine what quantity and then go from there. so it is going to involve vb. Obviously this is highly custom - and so there are several good coders that watch this sight and may contribute their time to this. I generally focus on immediate assistance with Access features. If you are going to manage and own this then you will want to invest in a good vb / vba text book and get to know the code side a bit.

    Sorry I'm not more helpful at this moment.

  3. #3
    broecher is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Sep 2010
    Posts
    38
    yeah, I was kind of thinking the answer would be difficult. But sometimes I think something is going to be difficult and there turns out to be an easy solution. I just needed confirmation from someone that this is in fact difficult.

    Thanks
    Last edited by broecher; 09-11-2010 at 03:18 PM. Reason: typo

  4. #4
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    I'd just like to reinforce that Access has an excellent embedded export capability that is well within the grasp of the new user/developer.

    It is your specific requirement of an automated method to determine & export a series of variable documents. This is a custom design. 'Difficult' is a relative term of course.

  5. #5
    hafaba is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    5
    Dim queryname(20) 'change this to the number of queries that you have

    Queryname(1)="Query1"
    Queryname(2)="Query2"
    ....

    For i = 1 to 20
    DoCmd.TransferText acExportDelim, "Standard Output", " & QueryName(i) & ", "C:\Temp\" & QueryName(i) & ".csv"
    Next i

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 0
    Last Post: 07-22-2010, 07:43 AM
  2. Export report to jpg
    By isdm in forum Reports
    Replies: 1
    Last Post: 04-16-2010, 10:00 PM
  3. Export
    By vvasudev in forum Import/Export Data
    Replies: 2
    Last Post: 01-20-2010, 11:42 AM
  4. Help Querying series
    By ktmchugh in forum Queries
    Replies: 20
    Last Post: 05-05-2009, 04:31 PM
  5. Export to Excel
    By vaikz in forum Import/Export Data
    Replies: 3
    Last Post: 03-25-2009, 09:37 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums