Export 2 Subforms to separate tabs in Excel

MissaLissa

New Member
Joined
Jul 2, 2013
Messages
26
I'm hoping someone can help me with this issue... or direct me in a more appropriate way to accomplish this.

I'm able to export 1 subform using a macro, but I'm unable to export 2 subforms to separate tabs using the same method.

Here is what I developed for the 1 subform export:

When you click on the View Register button, the delete query deletes all records in the CalPERS Register table, then appends records based on the start and end dates that were chosen on the main form. the subofrm then shows those records. I'm then able to create a simple ExportWithFormatting macro to export those records to excel.
Code:
Private Sub ViewRegister_Click()
DoCmd.SetWarnings False
 DoCmd.OpenQuery "qDel_CalPERS Register"
 DoCmd.OpenQuery "qApp_CalPERS Register"
 DoCmd.SetWarnings True
DoCmd.Requery ("tbl_CalPERS Register subform")
End Sub
I want to be able to do this same thing with 2 subforms. The difference between the 2 subforms is the client number. The subforms use the same table. I want to be table to export the records to the same excel spreadsheet but keep the 2 subforms on separate tabs.
Code:
Private Sub ViewRegister_Click()
DoCmd.SetWarnings False
 DoCmd.OpenQuery "qDel_Genworth Register"
 DoCmd.OpenQuery "qApp_Genworth Register"
 DoCmd.SetWarnings True
DoCmd.Requery ("tbl_Genworth_054 Register subform")
DoCmd.Requery ("tbl_Genworth_128 Register subform")
End Sub
Is this possible?

Thanks in advance for the help and/or suggestions.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qsData1", vFile, True,tab1
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qsData2", vFile, True,tab2
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

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