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
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