OasisUnknown
New Member
- Joined
- Oct 15, 2015
- Messages
- 46
Hello Everyone,
I am trying to set up an export menu so that I can either export my report to PDF or export it to Excel.
I have the functionality for the PDF portion working but I wanted to expand to excel and I might be thinking about the whole process the wrong way.
Here is what I am currently doing.
1. When I have the report open I have a button on the report that says export. on click it will launch my export form as such
2. On the form I have two additional buttons One says PDF the other says excel when you click the pdf button it launches this code
This all works but the issue that I run into when trying to incorporate excel. Since the report itself and all its formatting wont export to excel and look very nice I was thinking I have to gain access to the reports record set and just export that query/table that the data is driven from.
but in order to export the record set I need to gab its name in a string variable and pass it to my export form.
This is where my open args question comes into play. Currently I just pass the report name through the open args but can you pass more than one variable through the openargs. from what I have been reading the answer would be no.
I might be able to pass a string array through the open args but I am not really sure how to access that content on the other side in the form load call.
Am I going about this all wrong or does any one have any suggestions about what I could be doing better?
I am trying to set up an export menu so that I can either export my report to PDF or export it to Excel.
I have the functionality for the PDF portion working but I wanted to expand to excel and I might be thinking about the whole process the wrong way.
Here is what I am currently doing.
1. When I have the report open I have a button on the report that says export. on click it will launch my export form as such
Code:
Private Sub ExportCmd_Click()
Call ExportHandler(Me.Name)
End Sub
Public Sub ExportHandler(exportTarget As String)
DoCmd.OpenForm "frmExportMenu", acNormal, , , , acWindowNormal, exportTarget
End Sub
2. On the form I have two additional buttons One says PDF the other says excel when you click the pdf button it launches this code
Code:
Option Compare Database
Option Explicit
Dim targetRpt As String
Private Sub Form_Load()
targetRpt = Me.OpenArgs
End Sub
Private Sub ExportPDFCmd_Click()
DoCmd.OutputTo acOutputReport, targetRpt, acFormatPDF
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub
This all works but the issue that I run into when trying to incorporate excel. Since the report itself and all its formatting wont export to excel and look very nice I was thinking I have to gain access to the reports record set and just export that query/table that the data is driven from.
but in order to export the record set I need to gab its name in a string variable and pass it to my export form.
This is where my open args question comes into play. Currently I just pass the report name through the open args but can you pass more than one variable through the openargs. from what I have been reading the answer would be no.
I might be able to pass a string array through the open args but I am not really sure how to access that content on the other side in the form load call.
Am I going about this all wrong or does any one have any suggestions about what I could be doing better?
Last edited: