Saving Access Reports as PDF files -
i in process of generating report in access which, once generated, should saved save location user puts in.
here's block of code.
reportname = "appraisal_" & trim(str(year)) & "_" & me.empnr & "_" & veilig(me.empnr) & "_" & format(now(), "yyyy_mm_dd_hh_mm_ss") docmd.copyobject , reportname , acreport, "rpt_beoordelen" docmd.openreport reportname , acviewpreview, , "employeenr='" & me.empnr & "' , year=" & me.year docmd.outputto acoutputreport, "", acformatpdf, , true docmd.close acreport, reportname
this generates , displays report correct values. asks save location. and, once given, tries save file given location. flashes printing pdf give location window.
after program stops. no file can found @ given location , report still opened. debugging application shows me
docmd.close acreport, reportname
is never reached. not errormessage , have no clue going wrong. give me solution problem?
if having trouble getting docmd.outputto
work "active object" leaving objectname
empty (ref: here) try this:
open "rpt_beoordelen" report , save record source
query saved query named "rpt_beoordelen_base_data". create "rpt_beoordelen_data" saved query generic sql like...
select * rpt_beoordelen_base_data
...then make "rpt_beoordelen_data" record source
[rpt_beoordelen] report.
now change code question this:
reportname = "appraisal_" & trim(str(year)) & "_" & me.empnr & "_" & veilig(me.empnr) & "_" & format(now(), "yyyy_mm_dd_hh_mm_ss") docmd.copyobject , reportname , acreport, "rpt_beoordelen" dim cdb dao.database set cdb = currentdb dim qdf dao.querydef set qdf = cdb.querydefs("rpt_beoordelen_data") qdf.sql = "select * rpt_beoordelen_base_data employeenr='" & me.empnr & "' , year=" & me.year set qdf = nothing docmd.outputto acoutputreport, reportname, acformatpdf
that change invocation of docmd.outputto
1 not depend on "active object" , may yield results desire. (fwiw, it's way i've gotten method work generating pdf versions of reports.)
Comments
Post a Comment