Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDF Printing in multiuser environment

Status
Not open for further replies.

holgi123

Technical User
Sep 4, 2004
43
AU
Hi everyone,

I would like to ask for help on the following issue:

I have a multiuser environment and use a form to perform Telemarketing Calls.
When the agents want to submit a quote I want a PDF created, than copy it into an archive and generate a lotus email, with the order/quote form attached. Everything works fine, with one problem remaining: When two people are logged in the DBase the name generation during the PDF creation is somehow creating such a problem, that the proper name is not created, hence the function stops with (understandable) error "Can't find......blablabla.pdf".
As far as I understand it, the problem is created around the Caption statement, as this seems to not update each time a user runs the sub.
So, i.e. user 1 is on record # 007 and the pdf created should be PurchaseAgreement007.pdf, so far so good and it works the first time. Now user 1 uses this sub and she/he is on record 0815 so the pdf created should be PurchaseAgreement0815.pdf. This is where it becomes tricky. The pdf file is containing the correct info but does NOT apply the correct name ....0815.pdf, but rather 007.pdf. Therefore the SendNotesMail function stops with "...Can't find .....0815.pdf". As I said I think this caption is used to generate the name and it does not work or the users block each other so it can not update the name...or something else. I tried using the DoCmd.Save statement, but that does not work at all in multiuser (or at least I don't get it working).

I'm so much under pressure from the big boys and would appreciate it very much, if anyone out there has a good, easy and quick idea.

Here is some code:
============ Sub behind form ========
Private Sub PurchasePDF_Click()
DoCmd.SetWarnings False
DoCmd.OpenReport "PurchaseAgreement", acDesign
Reports![PurchaseAgreement].Caption = "PurchaseAgreement" & Forms!frmSales![Customer Number].Value
'DoCmd.Save
DoCmd.Close acReport, "PurchaseAgreement"
'Call the function to print it out.
Call PrinttoPDF("PurchaseAgreement", "L:\Telesales\CreatedPDF\PurchaseAgreement & Forms!frmSales![Customer Number].Value")
Dim PauseTime, Start, Finish
PauseTime = 15
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Finish = Timer
Call CopytoArchivePurchase
Kill "L:\Telesales\CreatedPDF\PurchaseAgreement" & Forms!frmMeterSales![Customer Number].Value & ".pdf"
Call SendNotesMail("Please find your order details attached", "L:\Telesales\CreatedPDF\Archive\PurchaseAgreement" & Forms!frmSales![Customer Number].Value & ".pdf", Forms!frmSales!CompanyContactEmail.Value, "", "True")
End Sub
===============

In the above SUB I used the following functions:

======= Print function ========
Public Function PrinttoPDF(rptname As String, outputfname As String) As String

Set Application.Printer = Application.Printers("PDFCreator")
DoCmd.OpenReport rptname, acViewNormal

Application.Printer = Nothing

End Function
===============================

The "CopytoArchivePurchase" and "SendNotesMail" functions works fine so I spare us all time in copying it here.

Many thanks in advance for any help and time spent on this topic.

Cheers
 
See if this works:
Code:
Private Sub PurchasePDF_Click()
[COLOR=blue]dim strCustNumber as String
strCustNumber = Forms!frmSales![Customer Number][/color]
DoCmd.SetWarnings False DoCmd.OpenReport "PurchaseAgreement", acDesign
[COLOR=blue]Reports![PurchaseAgreement].Caption = "PurchaseAgreement" & strCustNumber[/color]
'DoCmd.Save
DoCmd.Close acReport, "PurchaseAgreement"
'Call the function to print it out.
Call PrinttoPDF[COLOR=blue]("PurchaseAgreement", "L:\Telesales\CreatedPDF\PurchaseAgreement" & strCustNumber)[/color]
Dim PauseTime, Start, Finish
    PauseTime = 15
    Start = Timer
Do While Timer < Start + PauseTime
    DoEvents
    Loop
    Finish = Timer
Call CopytoArchivePurchase
[COLOR=blue]Kill "L:\Telesales\CreatedPDF\PurchaseAgreement" & strCustNumber & ".pdf"
Call SendNotesMail("Please find your order details attached", "L:\Telesales\CreatedPDF\Archive\PurchaseAgreement" & strCustNumber & ".pdf", Forms!frmSales!CompanyContactEmail.Value, "", "True")[/color]
End Sub


HTH
Lightning
 
Hi Lightning,

thank you so much, it works. Gosh, why didn't I figure that out myself :)

Again, much appreciated your quick and successful help.

Cheers
 
I am trying to print my Access reports to a PDF file but I am having problems and thought you might be able to help.

I reviewed your code and incorporated it into my code but for some reason I get "Method or Data Member not Found" on the following piece of code:

Set Application.Printer = Application.Printer("PDFCreator")

If I try to type Set Application. - Printer is not an option on the list. Any suggestions would be greatly appreciated.

Thanks,
 
Seems you have a little old access version ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top