Lebans Report to PDF

B

BruceM

Not sure if this is a form question or a report question or something else.
A couple of weeks ago I set up Lebans' Report to PDF, and it worked in a
test copy, but then I had to make some other changes to the database in a
bit of a hurry, so I left the test copy aside and made the other changes. I
added the Report to PDF modules, and used the same code as before in a
command button on the form. strPath is a hard-coded path to a network
folder and a file name based on the purchase order number. I left out the
details, but it is a legitimate path and file name.

Dim blnRet As Boolean
Dim strFileName As String

' Call the convert function
blnRet = ConvertReportToPDF("rptPO", , strFileName)

This is the place in the conversion module where the code gets tripped up
with error 3464, data type mismatch in criteria expression:

' Export the selected Report to SnapShot format
DoCmd.OutputTo acOutputReport, RptName, "SnapshotFormat(*.snp)", _
strPathandFileName

I tried it with just the basics:
DoCmd.OutputTo acOutputReport, "rptPO"

When I do it that way I am prompted for the format and for the output file
name. The same error occurs.

I have included only the problem line of code from the module, thinking that
it may not be necessary to post the whole thing. I expect a number of
people are familiar with the code, for one thing; for another, it seems the
problem may be with the information being received by OutuptTo, so perhaps
somebody has some ideas of what to look for.

The report is based on a filtered query (limited to the current record
only). I plan to change this so that the report's record source is a single
record loaded at run time (the Open event, I expect), but either way I
wonder if the problem is related to the PDF code not knowing which record to
use. I can't sort out from the code just how that works. The puzzling
thing is that it worked before, so it is probably a minor issue I am not
seeing.
 
P

Peter Hibbs

Bruce,

Coincidentally I had a very similar problem to yours only today. I
modified a report and tried to use Stephen's code to convert it to a
pdf file and the code just stopped running when it got to the same
line as yours did (the DoCmd.OutputTo acOutputReport, RptName, ...).
No error messages though, no Compile errors either, the code just
quit.

It turned out to be an error in the report's VBA code, I was trying to
reference a field in the Header section with some code in the Report
Open event, when I fixed that it worked fine.

I would suggest you check the report thoroughly, perhaps try a
different report which has worked. If that doesn't fix it then I have
no other ideas.

HTH

Peter Hibbs.
 
B

BruceM

I tried creating an unbound report, and used the pdf utility to create a pdf
based on that. It worked, so I reworked the problem report's Record Source.
When printing the report from the form I was passing a Where condition in
the OpenReport code. Instead of doing that I used information from the form
(Forms!frmPO!txtPO_Number) form as the report's Record Source query
criteria. This loads a single record, and now the pdf utility works quickly
and smoothly. The report loads more quickly, too. I had been meaning to
change the Record Source anyhow. It looks as if I should have done that
first.

I still don't know exactly what the problem was. I can only guess that the
pdf utility did nto have a way to focus on a single record, as it did not
have the Where condition I used for the report.

Lebans comes through yet again!
 

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