pdf file per record creation from form

G

Guest

I am trying to save each record in a form, call it frmData, as a separate pdf
file with a name corresponding to a field on the master form. The purpose is
put pdf data on a web site with each pdf record accessible as a separate file.

Without getting into detail, I do this:

From the master form- I rename frmData to match field on master, say FieldName
Open form FieldName
SendKeys "%(f)pa~%(s)" to print to adobe
Close form FieldName
Rename FieldName back to frmData
Goto next record on master from (source of next Fieldname)
Loop until last record

My problem is that it works fine on my computer (w2000 access 2000) but on
one user's computer, (xp, w2003), it will print the first 10 or so records,
then cycle all the way to the end withou printing any more files. Is there a
better way to do this? If not, do I have to do something different for
Access 2003?
 
G

Guest

Are you trying to print a screen/form or a report?

Because if it's a report then you can automate the whole thing.
By printing it to the PDF Writer e.g. for adobe you can print automatically
by setting the filename of the file before printing in the registry.
 
G

Guest

Cold you be more specific, show essential code. It seems to me that I have
to use send keys if i don't want each record print to stop for a dialog box
I can easily change the form to a report. I am printing a record, not the
screen.

Also, is there something about code that I don't know that would allow the
system to loop correctly for a dozen or so, then quit printing while still
cycling through the loop?
 
G

Guest

Use this document:
http://partners.adobe.com/public/de...tion_apis_and_specs/DistillerAPIReference.pdf
This describes (bottom of page 20) how to set the destination path and
filename by setting a registry key. This key will be active for the next
document that is printed to the Adobe PDF printer.

The complete process would look like this:

set the registry key
print to the Adobe PDF printer
open the PDF file with the code that you already have so that you can modify
it.


Make sure that your report has the pdfwriter as default printer and you have
to set the registry key before calling the docmd.openreport for each record.
 
G

Guest

We don't seem to be communicating. What I am trying to do is convert each
record in a form or a report to a matching unique pdf file by by clicking a
button on a master form. If I have 200 records, there will be 200 uniquely
named pdf files. I have no problem saving indiviual records in pdf using
code I developed. My problem is that my code doesn't work consistently on
a client's XP computer with access 2003. I developed code in access 2000 and
windows 2000. Is the problem the ambiguity of SendKeys command that I
described in first submittal? Is there a surer way to convert each record in
a report or form to a separate pdf file, each with a unique name?. You said
something in your first reply to the effect that it would be simple with
reports as opposed to forms. Please amplify.
 
G

Guest

I haven't seen a reply to my last response. I'm not sure of the procedure
here. Does this mean that there is no answer, or are you just unavailable?.
I have to know so that I can pursue other solutions
 
J

John Nurick

There are two obvious problems in your code. The first is that you are
using Sendkeys, which should only ever be the last resort, not least
because it is so difficult to ensure that your keystrokes are being sent
to the correct place. The second is that you are changing the design of
the form (by renaming it); this should never be necessary in normal
operation, and I can't see why you're doing it here.

Probably the way to go about what you want is

1) ensure that the report will print to the PDF-writing device

2) open a recordset that contains in effect a list of the records you
want to export (e.g. the primary key of the table)

3) for each record in the recordset
i) set the default path and filename for the PDF device
as described by Raoul
ii) build a WHERE condition that selects just that one
record
iii) pass the WHERE condition to DoCmd.OpenReport.
 
G

Guest

Hi,

Basically SendKeys are available but will be blocked more and more since
they create a vulnarability for automated tasks as you can see with xp and
office2003.

So I guess you should rewrite this and try to avoid sendkeys.
 
G

Guest

I thank you and others for all the time spent on this, but still have some
questions. John Nurick says that there are problems with the wiith the code,
but the code runs great on three computers now,just on one has problems so
far (the most important one). Before I leave the thread, I would like to
make sure that I a understand the real problem and ask one last question.

As I understand you and John:
1-The SendKeys command is not reliable across computers. That seems to be
the root of my problem.
2-Since i don't want the code to be interrupted by the print to adobe dialog
box as it prints each record, and SendKeys is unreliable, my only choice is
mess with the registry keys.

Question, where do I find how to some basics about registries (I only
vaguely know what they do) and how to change one, and, if I do change one, do
I have to do it for each client'scomputer using the program?
 
G

Guest

Well it's fairly easy

You don;t have to do anything on the clients computer.
You only have to set the registry key before you execute the docmd.openreport

Acrobat will automatically detect that this key is set with a filename and
will automatically save the pdf to this location after the printing the
registry key is reset by acrobat.

For more documentation check the Link below.
 
G

Guest

Raoul-you forgot to put in the link. thamks in advance-I sure want to get
this working. GG
 
G

Guest

I hate to keep this going, but that link is some complex thing for Adobe
pros. Please let me know where I can find what a registry key is and how I
go about changing it. I hope that Access comes up with some easy way to
bypass dialgog boxes or makes SendKeys more dependable.
 

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