TransferSpreadsheet from Excel to Access or Vice-versa

Stacy Rueda

Board Regular
Joined
Jun 23, 2016
Messages
87
Hi All, I hope someone can help me..

My problem is, I have Report in MS Access with Main form and subform on which subform linked to main form. How can I export to excel the main and subform altogether, because as of now I can't export both. I have found a code below on the net but I don't know how to execute in Access, or maybe someone knows how to directly get/linked data from excel to Access. Thank you, please help me.. My boss keeps asking me for this report. Please..

Code:
[COLOR=#660066][FONT=inherit]DoCmd[/FONT][/COLOR][COLOR=#666600][FONT=inherit].[/FONT][/COLOR][COLOR=#660066][FONT=inherit]TransferSpreadsheet[/FONT][/COLOR][COLOR=#000000][FONT=inherit] acExport[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] acSpreadsheetTypeExcel12[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] [/FONT][/COLOR][COLOR=#008800][FONT=inherit]"Table1 Query"[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] [/FONT][/COLOR][COLOR=#008800][FONT=inherit]"C:\Book1.xlsx"[/FONT][/COLOR]
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
2,173
you can either export them to different sheets:
Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12,"Table1 Query","C:\Book1.xlsx", "sheet1"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12,"Table2 Query","C:\Book1.xlsx", "sheet2"

or make a query, that joins both tables into a single dataset, then export that:
Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12,"qsJoinQry","C:\Book1.xlsx", "allTogether"
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,329
Messages
5,836,675
Members
430,444
Latest member
WrenchBoy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top