Results 1 to 5 of 5
  1. #1
    HansBades is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2021
    Posts
    85

    Access Export to Excel


    I am transferring a query from access to excel (DoCmd.TransferSpreadsheet) in access vba and within the code I am formatting the spreadsheet once it is created. However, I would like to be able to put two exports, which are two queries each to a single workbook, into the same workbook. When I try to use the move method within the access vba code, it is not working. Any ideas?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    11,342
    Here's one idea - show your code (and please use code tags - # button on posting toolbar). Or maybe you already knew that.
    Impossible to suggest anything specific as there could be several reasons. Might help to know what the count is in your recordset as well.
    You could also consider automation as an approach:
    http://www.accessmvp.com/KDSnell/EXCEL_Export.htm
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    3,092
    You could use CopyFromRecordset ? https://docs.microsoft.com/en-us/off...yfromrecordset
    I presume you mean the sane worksheet?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    2,435
    If the Column data types and field names are the same you could union the 2 queries into one, but that might not suit your desired output or layout.

    If not automation is the only way to go.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    Join Date
    Apr 2017
    Posts
    1,427
    Where is this generated Excel workbook used? I ask this, because only sane reason to save it through code is when it will be sent to another location (non in same LAN) and opened there!

    In case it will be used in same LAN, much better way is to create a saved query in your Access BE, and create an Excel workbook, which reads this query in (e.g. when opened).

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

Similar Threads

  1. Replies: 2
    Last Post: 05-19-2021, 02:38 AM
  2. Export from Access to Excel
    By Giulio Benvenuti in forum Access
    Replies: 1
    Last Post: 03-11-2021, 04:21 PM
  3. Replies: 3
    Last Post: 04-07-2016, 04:36 AM
  4. Replies: 7
    Last Post: 04-25-2013, 03:47 PM
  5. Export from Access to Excel
    By Eowyne in forum Import/Export Data
    Replies: 5
    Last Post: 04-23-2011, 07:08 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