Stephen Lebans Report2PDF

S

Silvester

NB: That code will work only if the user is logged in as administrator or
has admin privileges on his reports. Else he will get a "no permissions for
XYZ report." alert because it involves opening the report, saving the
filter, then resetting the filter and saving the report again.

The following duh roundabout code works even if there is no admin privs
granted... Its not elegant but it's functional.

To batch convert reports to pdf using a loop, insert this into the loop

stLinkCriteria = "[Some Field]=" & "'" & msomevalue & "'"
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
DoCmd.Minimize
Call convertreporttopdf(stDocName, ,
strPDFOutputFilePathAndName & ".pdf", False, False)
DoCmd.Close acReport, stDocName


Stephen Lebans said:
Have you tested this extensively Sylvester?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Silvester said:
Ok, Here's my 2c worth until Stephen comes up with a where clause
filter...

Here's how I pass on filters to reports being batch converted to pdf in a
loop. Works great for me.

stLinkCriteria = "[Some Field]=" & "'" & msomevalue & "'"
'save the report filter
Call SetReportFilter(stDocName, stLinkCriteria)
Call convertreporttopdf(stDocName, , strPDFOutputFilePath & ".pdf",
False, False)
'reset report filter to nothing
Call SetReportFilter(stDocName, "")

----------------------------------------------------------
' This code credit goes to Crystal
http://www.utteraccess.com/forums/u...hat=showflat&page=&view=&sb=5&o=&fpart=1&vc=1

Sub Report_SetReportFilter(pReportName, pFilter)
Dim rpt As Report
DoCmd.OpenReport pReportName, acViewDesign
Set rpt = Reports(pReportName)
rpt.Filter = pFilter
rpt.FilterOn = true
DoCmd.Save acReport, pReportName
DoCmd.Close acReport, pReportName
Set rpt = Nothing
End Sub
 
S

Stephen Lebans

Perfect...thanks!

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Silvester said:
NB: That code will work only if the user is logged in as administrator or
has admin privileges on his reports. Else he will get a "no permissions
for XYZ report." alert because it involves opening the report, saving the
filter, then resetting the filter and saving the report again.

The following duh roundabout code works even if there is no admin privs
granted... Its not elegant but it's functional.

To batch convert reports to pdf using a loop, insert this into the loop

stLinkCriteria = "[Some Field]=" & "'" & msomevalue & "'"
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
DoCmd.Minimize
Call convertreporttopdf(stDocName, ,
strPDFOutputFilePathAndName & ".pdf", False, False)
DoCmd.Close acReport, stDocName


Stephen Lebans said:
Have you tested this extensively Sylvester?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Silvester said:
Ok, Here's my 2c worth until Stephen comes up with a where clause
filter...

Here's how I pass on filters to reports being batch converted to pdf in
a loop. Works great for me.

stLinkCriteria = "[Some Field]=" & "'" & msomevalue & "'"
'save the report filter
Call SetReportFilter(stDocName, stLinkCriteria)
Call convertreporttopdf(stDocName, , strPDFOutputFilePath & ".pdf",
False, False)
'reset report filter to nothing
Call SetReportFilter(stDocName, "")

----------------------------------------------------------
' This code credit goes to Crystal
http://www.utteraccess.com/forums/u...hat=showflat&page=&view=&sb=5&o=&fpart=1&vc=1

Sub Report_SetReportFilter(pReportName, pFilter)
Dim rpt As Report
DoCmd.OpenReport pReportName, acViewDesign
Set rpt = Reports(pReportName)
rpt.Filter = pFilter
rpt.FilterOn = true
DoCmd.Save acReport, pReportName
DoCmd.Close acReport, pReportName
Set rpt = Nothing
End Sub
 

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