Link to home
Start Free TrialLog in
Avatar of cruderhays
cruderhaysFlag for United States of America

asked on

How do I create Command Button in an Access Form to print PDF file and Current Record

I would like to create a command button in a Access 2003 form that would allow me to print the current record in addition to a pdf file.  Is this possible?
Avatar of eg252
eg252

there are many ways - but one simple pimple way is to create 2 reports, make one print to the pdf printer and one to the default (or other printer) then just print both - for example:
docmd.openreport "report1",,,"key=" & me!currentid
docmd.openreport "report2,,,"key=" & me!currentid
Avatar of Jeffrey Coachman
cruderhays,

I will presume that you already have a .pdf Utility installed that is viewed as a Printer.

You can use something like this as well, and you will not need to create two separate reports:
    Access.Printer = Access.Printers.Item("hp LaserJet 1010 Series Driver")
    DoCmd.OpenReport "rptYourReport", acViewNormal, , , acHidden
    DoCmd.Close acReport, "rptYourReport"
   
    Access.Printer = Access.Printers.Item("CutePDF Writer")
    DoCmd.OpenReport "rptYourReport", acViewNormal, , , acHidden
    DoCmd.Close acReport, "rptYourReport"

You would have to insert your *exact* printer name into the .Item argument.

To get a list of exact printer names use something like this:
Dim prt As Printer
Dim strPrinterList As String

    For Each prt In Printers
        strPrinterList = strPrinterList & ", " & prt.DeviceName
    Next prt
   
    MsgBox Right(strPrinterList, Len(strPrinterList) - 2)

JeffCoachman
Avatar of cruderhays

ASKER

Those are both great solutions - however after looking at my question I worded it wrong.  I actually need to print the current record and also print a pdf file that corrolates to that record. The pdf file is located on our network drive.  Thaks for your help.
cruderhays,

Then let's be even more specific...

- Print the current Record from what? A table or a form?
- Is the PDF file created already, and just needs to be printed?
- How is the current Record tied to the PDF File? Is there a Path to the PDF in the record?

JeffCoachman
I would like to print the current record from a form.  The pdf is already created and does just need to be printed.  Basically I just need to stream line the process for the end user so that he doesn't have to hunt for the file. The end user would like it to be able to duplex the current record on the front of the page and the pdf file printed on the back of the page.  I would like to include a path to the pdf file in the record, however I'm not quite sure how to do that.  I was going to give the pdf file name the number of the record.  Example -  for record # 23 there would be a pdf file called 23.pdf.  
cruderhays.
?

The questions seems to have morphed again.
Now you need duplex printing?

Please restate the question again.

JeffCoachman
Sorry - this is my first time posting a question.  Ok so here's the jist - I have a database with records that need to correlate to diagrams which are already created pdf files.  I have created a form for the data entry of the records. On the form the user needs to be able to click a command button that will duplex print the current record on the form and it will also need to print a diagram (already created pdf file).  Example - the front page beining the current record from the form and the back page being the pdf diagram.  
cruderhays,

As far as I know you cannot Duplex print two separate print jobs (The record and the PDF)

Your best bet would be to print one job, then turn the papers over and print the second job.

How would you like to proceede?

JeffCoachman
Thanks for all your help - I guess the avenue I'd like to take is to have a command button that prints the current record (which  I alrady know how to create) and create a command button that prints the pdf file in corrolation to the record number.  I was going to give the pdf file name the number of the record.  Example -  for record # 23 there would be a pdf file called 23.pdf.  So the command button would print the pdf file containing the record number.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Works Prefect - Thanks so much for you help!
Thanks so much for your help and patience!