Solved

how to export the contents of a subdatasheet to excel using vba

Posted on 2008-06-11
5
1,207 Views
Last Modified: 2013-11-27
Experts, right now am using VBA to automatically run a query that creates a table with subdatasheets. The program then automatically exports the primary table to excel. My question is, how do i reference the subdatasheets so that i can automatically export these to excel as well? Below is the code i am currently running to export the primary sheet
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "PRIMARYTABLE", sFn, True, "6B_LinkFileReferences!A1:J1"

Open in new window

0
Comment
Question by:Forensicon
  • 2
5 Comments
 
LVL 3

Expert Comment

by:BitRunner303
ID: 21762837
If the subdatasheets are queries or tables they can be exported using the same function.
If it's a form or report though, use the DoCmd.OutputTo command to export:

e.g.

DoCmd.OutputTo acOutputForm,"MySubDataSheet",acFormatXLS,"C:\MyFile.xls",True
0
 

Author Comment

by:Forensicon
ID: 21763048
How do i know what the subdatasheet name is, i can't figure out where/if i named it? Below is the code i use to create the subdatasheet.
SetFieldProperty CurrentDb.TableDefs![LNK_Link Files grouped by Serial Number with MinMax Dates], "SubdatasheetName", dbText, "LNK_Link Files by Link File Name"
SetFieldProperty CurrentDb.TableDefs![LNK_Link Files grouped by Serial Number with MinMax Dates], "LinkChildFields", dbText, "Serial"
SetFieldProperty CurrentDb.TableDefs![LNK_Link Files grouped by Serial Number with MinMax Dates], "LinkMasterFields", dbText, "Serial"

Open in new window

0
 
LVL 3

Accepted Solution

by:
BitRunner303 earned 500 total points
ID: 21763102
Look in your Forms tab, usually if you create a SubDatasheet by the Wizards it'll create a separate Form object for it.

In this case though wouldn't it be called "LNK_Link Files by Link File Name" as you specified?

However, what I would probably do is just design a query linking the data, then do a TransferSpreadsheet on the query to export it to Excel that's a much cleaner method.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question