Results 1 to 8 of 8
  1. #1
    fordowns is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    4

    22 access queries into one xlsx as different sheet tabs please


    Hello.

    I have been shadowing your site for a while now. You guys seem to really have it together as a team across the world.
    I have a stumbling block. I have 22 access queries that for some time now I have been trying to export results into one workbook, each having it's own sheet. May I ask permission to post what I have so far for some debugging help please?

    I have table made that lists the 22 queries for looping to next but can not seem to learn how to incorporate this either.

    I just started using access 2010 this year so yes I am another newbie. I understand if you guys are busy.
    tx
    Fordowns

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can certainly post what you have so far. A recordset would likely be used to loop the table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    fordowns is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    4
    Here is what I have so far. It just throws them out into 22 spreadsheets. Then I have to manually combine them into one file.
    I can not figure out looping it. I have all the query name and desired sheet names listed in a table called 'outputprocessing' . That is where I get stuck.
    How to keep the export looping back to it instead of the long hand you see below. If anything obvious comes to mind, I would really appreciate it. I know most of you probably have a full plate already but thought maybe one of you has been down this road before maybe. Thanks so much.



    Function ExportBackups()
    On Error GoTo ExportBackups_Err

    MsgBox "File should be at: \Planning Systems\Dimensions Snapshots", vbInformation, "File Loc of Final Export"
    DoCmd.OutputTo acOutputQuery, "BA_01DEPT", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BA_01DEPT_20xx-MM-DDTxxxx.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BA_02ACCT", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BA_ACCT.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BA_03JOBCODE", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BA_JOBCODE.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BA_04BILLINGAREA", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BA_BILLINGAREA.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BA_05PHYSID", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BA_PHYSID.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BA_06PAYTYPE", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BA_PAYTYPE.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BAP1_01DEPT", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\20XX-MM-DDTxxxx_BAP1_DEPT.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BAP1_02ACCT", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BAP1_ACCT.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BAP1_03JOBCODE", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BAP1_JOBCODE.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BAP1_04PAYTYPE", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BAP1_PAYTYPE.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BAP1_05GLPERIOD", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BAP1_GLPERIOD.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BAP1_06PROVIDER", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BAP1_PROVIDER.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BAP1_07CPT", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BAP1_CPT.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BAP1_08DTYPE", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BAP1_DTYPE.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "BAP1_09FINCLASS", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\BAP1_FINCLASS.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "CAA_01PROJECT", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\CAA_PROJECT.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "CAA_02CODE", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\CAA_CODE.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "CAA_03PAYOR", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\CAA_PAYOR.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "HA_01MODEL", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\HA_MODEL.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "HA_02CODE", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\HA_CODE.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "HA_03PAYOR", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\HA_PAYOR.xlsx", False, "", , acExportQualityPrint
    DoCmd.OutputTo acOutputQuery, "HA_04SCENARIO", "ExcelWorkbook(*.xlsx)", "\\work.edu\dfs\0004\0044\44001\Planning Systems\Snapshots\HA_SCENARIO.xlsx", False, "", , acExportQualityPrint


    ExportBackups_Exit:
    Exit Function

    ExportBackups_Err:
    MsgBox Error$
    Resume ExportBackups_Exit

    End Function

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm just on an iPad right now, but have you tried outputting them all to the same file? Either OutputTo or TransferSpreadsheet will create different sheets for each.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    fordowns is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    4
    You have me curious now. Did not know this existed. Is this office 2013 command? Will it work in access 2010?
    I put one of these statement before each query statement or after each ?? (quick sample where to insert it maybe?) Thank you again btw.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    See if Ken Snell example can help http://www.accessmvp.com/KDSnell/EXC...ExportSameFile
    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
    fordowns is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    4
    I thank you. I did look at this while back. Can I replace his tables with queries and it still work same?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Yes. Export table or query.

    You can open a recordset of the table with query names, loop through that recordset, and use one dynamically structured TransferSpreadsheet line to export each query.
    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. Export Queries to Excel tabs with Save as Dialog box
    By deepanadhi in forum Import/Export Data
    Replies: 1
    Last Post: 05-16-2012, 10:36 AM
  2. Replies: 2
    Last Post: 05-03-2012, 08:03 AM
  3. Open Excel .xlsx file from Access
    By Bigmix in forum Programming
    Replies: 6
    Last Post: 02-28-2012, 09:55 AM
  4. Replies: 1
    Last Post: 12-02-2011, 10:43 AM
  5. Form with Tabs and multiple external queries
    By chris.williams in forum Forms
    Replies: 3
    Last Post: 11-16-2011, 06:20 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