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 total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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"
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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
Back
Top