Results 1 to 2 of 2
  1. #1
    scubaninjanz@gmail.com is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2018
    Posts
    1

    Produce xls files from a query for individual entries in a given field

    I am looking for a method to quickly extract multiple excel files to a predefined location for each unique field in a data query. Ideally with a single click or maybe click and then prompt for file location.

    For example:

    Field A Field B Field C
    A Cat Apple
    A Dog Orange
    B Horse Banana
    B Mouse Pineapple
    B Dog Pear
    C Elephant Apple
    C Cat Mandarin
    D Chipmunk Apple
    D Monkey Banana

    From this file produce for individual excel files saved to a given location for each unique entry in Field A.

    A.XLS
    Field A Field B Field C
    A Cat Apple
    A Dog Orange

    B.XLS
    Field A Field B Field C
    B Horse Banana
    B Mouse Pineapple
    B Dog Pear

    C.XLS


    Field A Field B Field C
    C Elephant Apple
    C Cat Mandarin

    D.XLS
    Field A Field B Field C
    D Chipmunk Apple
    D Monkey Banana

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    make a form, with a list box, the list shows all the unique recs of Field A
    A
    B
    C
    D

    the query to send, qsMyRpt, will look at what is selected in the list ,
    select * from table where [fieldA]=forms!myForm!lstBox

    a button to run the code to scan the list and export,
    Code:
    sub btnMake_click()
    dim i as integer
    dim sUnit as string 
    dim vFile
    
    for i = 0 to lstBox.listcount - 1
       sUnit = lstBox.ItemData(i)   'get next item in list
       lstBox = sUnit              'set list to that item for the query to read
    
       vFile = "c:\temp\" & sUnit & ".xls"
    
       DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "qsMyRpt", vFile, True, sUnit
    next
    end sub

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

Similar Threads

  1. Multiple page reports to individual files
    By Gina Maylone in forum Access
    Replies: 1
    Last Post: 10-20-2018, 10:41 AM
  2. Replies: 0
    Last Post: 07-27-2016, 11:21 AM
  3. how to Capture Individual User who made entries in form
    By bronson_mech in forum Programming
    Replies: 2
    Last Post: 08-19-2013, 10:07 AM
  4. Replies: 5
    Last Post: 07-06-2012, 03:22 PM
  5. Replies: 3
    Last Post: 09-24-2010, 02:48 PM

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