Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-06-11
5
Medium Priority
?
1,346 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:Yaniv Schiff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Yaniv Schiff
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 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

604 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