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