One report to separate PDF's

B

Bill

Ok, so I have a input screen broken into tabs. At the top (header) I have
the print function which sends the complete report to a single PDF
(reporttopdf). What I would like to do now, is add a new tab and that tab be
sent to a separate report. Basically the system will need to generate two
reports (the first containing tabs 1-5 and the second containing tab 6) and
I'm not sure how to accomplish this. Thank you!!!
 
D

dymondjack

Bill,

You would probably need to run two queries on the underlying data of the
form. The first one to gather information on tabs 1-5, and a second to pull
data for tab 6. Keep in mind that the form record would need to be saved
before querying these two sets of information.

That said, I would modify the code behind your print button to:
a) save the record (RunCommand acCmdSaveRecord)
b) run the two queries
c) print report #1
d) print report #2

Of course, you would need to modify the source for each report to use data
from each respective query.

I am not sure of any way to take a single report and have it print
separately (that sort of defeats the purpose of reports), but maybe someone
else knows a way other than what I've suggested.

--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery
 
B

Bill

Thank you. This sounds like what I need to do but I don't know how to fit it
into my code. I'm using the reporttopdf coding.

Private Sub Print_Rpt_Click()
' ok lets start the record to print
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ReportID] = """ & Me.[ReportID] & """"
DoCmd.OpenReport "IR_Report", acViewPreview, , strWhere
End If

' ok now lets try to export it to a PDF hopefully using the IR number in
the filename

strReportName = "IR_Report"
DoCmd.OpenReport strReportName, acViewPreview, , strWhere
Reports(strReportName).Visible = False 'hide the internal print command

Call ConvertReportToPDF("IR_Report", , _
"K:\Security 2\Reports\" & Me.ReportID & ".pdf", False, True) 'path to
location to save file with file name

DoCmd.Close acReport, strReportName

How would I run the two queries using this script?

Thank you.
 
D

dymondjack

As you are specifically telling the report to only run the report on a
specified ID, then you either a) need to reset the report ID criteria for
your second report, or b) run a completely different report the second time
around. Because obviously, the same report ran with the same criteria twice
in succsession is going to be exactly the same output...

Keeping that in mind, this should be fairly self-explanitory. After you
close the first report, just reset either a) the strWhere, or b)
strReportName, and then you would open the report again, and run the same
convertreporttopdf again, just like you did the first time.

--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery


Bill said:
Thank you. This sounds like what I need to do but I don't know how to fit it
into my code. I'm using the reporttopdf coding.

Private Sub Print_Rpt_Click()
' ok lets start the record to print
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ReportID] = """ & Me.[ReportID] & """"
DoCmd.OpenReport "IR_Report", acViewPreview, , strWhere
End If

' ok now lets try to export it to a PDF hopefully using the IR number in
the filename

strReportName = "IR_Report"
DoCmd.OpenReport strReportName, acViewPreview, , strWhere
Reports(strReportName).Visible = False 'hide the internal print command

Call ConvertReportToPDF("IR_Report", , _
"K:\Security 2\Reports\" & Me.ReportID & ".pdf", False, True) 'path to
location to save file with file name

DoCmd.Close acReport, strReportName

How would I run the two queries using this script?

Thank you.

dymondjack said:
Bill,

You would probably need to run two queries on the underlying data of the
form. The first one to gather information on tabs 1-5, and a second to pull
data for tab 6. Keep in mind that the form record would need to be saved
before querying these two sets of information.

That said, I would modify the code behind your print button to:
a) save the record (RunCommand acCmdSaveRecord)
b) run the two queries
c) print report #1
d) print report #2

Of course, you would need to modify the source for each report to use data
from each respective query.

I am not sure of any way to take a single report and have it print
separately (that sort of defeats the purpose of reports), but maybe someone
else knows a way other than what I've suggested.

--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top