Results 1 to 8 of 8
  1. #1
    turntabl1st is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    9

    Export Access into multiple excel files based on field value

    I have a service database that when a button is pressed I would like multiple excel spreadsheets to auto-generate to a defined location based on 2 feild values in 2 separate tables

    Requirements:
    1. the first value will be territory ID and I would like every unique value in this field to produce and new excel file


    2. the second value Instrument Type is a lookup feild on a separate table and i would like each unique value to be a separate tab in each of the workbooks that was previously produced


    here is an example SQL statement for one tab on one workbook:
    Code:
    SELECT Instruments.Institution, Instruments.Territory, Instruments.LastName, Instruments.FirstName, Instruments.SerialNum, Instruments.PurchaseDate, Instruments.WarrantyPeriodStart, Instruments.WarrantyPeriodEnd, Instruments.WarrantyQuoted, Instruments.AnnualPM, Instruments.AnnualPMStatus, Instruments.[6MonthPMMonth], Instruments.[6MonthPMStatus], Instruments.[2013Service], Instruments.[2012Service], Instruments.[2011Service], Instruments.[2010Service], Instruments.[2009Service], Instruments.Notes, Instruments.City, Instruments.State, Instruments.Zip, Instruments.Instruments, Instruments.WarrantyType, IntrumentTypes.Instruments
    FROM IntrumentTypes INNER JOIN Instruments ON IntrumentTypes.ID = Instruments.Instruments
    WHERE (((Instruments.Territory)=103) AND ((IntrumentTypes.Instruments)="autoMACSClassic"));
    Here is how i have previously generated the reports before many more territories were added and automation became a necessity
    Code:
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, _
    "qryautoMACSclassic", strPath, True
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, _
    "qryautoMACSpro", strPath, True
    End If
    I did find this but do not know how relevant to my situation it is http://www.accessmvp.com/KDSnell/EXC...ExportSepFiles

    any help would be greatly appreciated

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Looks very relevant.

    Modifying query with QueryDefs collection is one approach, maybe the easiest.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    turntabl1st is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    9
    I am not going to lie, I am still extremely confused on how to get this up and running. I keep getting various errors.

    My Tables are: Instruments, InstrumentTypes
    My Fields are: Instruments.Territory, Instruments.Instruments, IntrumentTypes.Instruments

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    What errors? Cite the exact message.

    Post your code or provide db for analysis. Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    turntabl1st is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    9
    Here is the database. I would like this to happen on a button press and ideally export depending if the chkbox is pressed for that territory. Thanks again for all the help as I have been pretty lost !
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Don't see that code in your db. I want to help but not build for you. Judging by the code already in the db you have enough understanding of VBA to adapt a given example. Attempt code and when you have specific issue, post question on it.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    turntabl1st is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    9
    Sorry I removed as much as of the database as possible(tables, queries, and forms) and removed the code that did not work from the button. I merely left the most necessary tables and the new form that I wanted to use for the button. I did not want my company's information out there like that. Thank you either way

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I understand removing real data as structure is what we are analyzing (a few dummy records for testing is helpful). Can't analyze your efforts if you remove it.

    Learn debug techniques. Review link at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 5
    Last Post: 07-06-2012, 03:22 PM
  2. Replies: 4
    Last Post: 06-14-2011, 07:19 PM
  3. Export multiple records based on a field
    By dskulman in forum Import/Export Data
    Replies: 0
    Last Post: 03-03-2011, 02:44 PM
  4. Replies: 1
    Last Post: 02-21-2011, 09:55 PM
  5. Export Query to Various Excel Files
    By dalet in forum Import/Export Data
    Replies: 7
    Last Post: 11-09-2009, 09:22 AM

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