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 File and Multi-User

Status
Not open for further replies.

holgi123

Technical User
Sep 4, 2004
43
AU
Hi everyone,
I'm really desperate as I do not get something working. I have a multi-user environment, where employees perform Telemarketing and try and close orders over the phone.

I want to create a PDF file, store it on the server, than pick it up as an attachment into Lotus Notes. The file name is generated as RentalAgreement&Customer Number. Customer Number is a field on the form.
Everything works fine if one user is logged in. It appears the problem is the following:

1. User 1 goes to record with Customer Number 001

2. PDF gets created and stored in folder as RentalAgreement001.pdf
3. Than the file gets copied into Archive folder and deleted, still having name RentalAgreement001.pdf

4. Than an email gets created and it pickes up the file from under 3 (from the Archive Folder).

So far so good

5. User 2 goes to record with Custromer Number 999

6. PDF gets created BUT NOT with correct Customer Number but rather with customer number from user 1. so INSTEAD of creating RentalAgreement999.pdf it creates RentalAgreement001.pdf

7. Therefore code stops after step 2 and I get an error message ".....file not found" which is understandable.

I'm so desperate to get this worked out, that I would really appreciate some help.

Here is my code so far:
==============================
Private Sub RentalPDF_Click()
Dim strCustNumber As String
strCustNumber = Forms!frmMeterSales![Customer Number].Value

DoCmd.SetWarnings False
DoCmd.OpenReport "RentalAgreement", acDesign
Reports![RentalAgreement].Caption = "RentalAgreement" & strCustNumber
DoCmd.Close acReport, "RentalAgreement"

'Call the function to print it out.
Call PrinttoPDF("RentalAgreement", "L:\Telesales\CreatedPDF\RentalAgreement & strCustNumber")
Dim PauseTime, Start, Finish
PauseTime = 15
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Finish = Timer
Call CopytoArchiveRental
Kill "L:\Telesales\CreatedPDF\RentalAgreement" & strCustNumber & ".pdf"
Call SendNotesMail("Please find your order details attached", "L:\Telesales\CreatedPDF\Archive\RentalAgreement" & strCustNumber & ".pdf", Forms!frmMeterSales!CompanyContactEmail.Value, "", "True")
End Sub
========================

I also have three functions: PrinttoPDF, CopytoArchiveRental and SendNotesMail, which all work fine, so I do not place them here.

I think it has to do with record locking but I do not get it working. I even try and place the [Customer Number] into a new dummy field and than use the dummy field in above code, but still no success as it than simply and wrongly puts the wrong number in the dummy field.

Again, I would really appreciate it if someone can help me with this as I do not know what else to do.

Many thanks and best regards
 
Shouldn't this:
Call PrinttoPDF("RentalAgreement", "L:\Telesales\CreatedPDF\RentalAgreement & strCustNumber")
Be this ?
Call PrinttoPDF("RentalAgreement", "L:\Telesales\CreatedPDF\RentalAgreement" & strCustNumber)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV,

thank you very much for your repsonse and the help you offered. I amended the code but unfortunately no luck. It still does not produce the correct file name when the second user starts using the feature, as it keeps on taking customer number from the fist chosen record, hence later code stops and I keep on getting the error message.

here is the current code:
=========================
Private Sub RentalPDF_Click()
Dim strCustNumber As String
strCustNumber = Forms!frmMeterSales![Customer Number]
DoCmd.SetWarnings False
DoCmd.OpenReport "RentalAgreement", acDesign
Reports![RentalAgreement].Caption = "RentalAgreement" & strCustNumber
'DoCmd.Save
DoCmd.Close acReport, "RentalAgreement"

'Call the function to print it out.
Call PrinttoPDF("RentalAgreement", "L:\Telesales\CreatedPDF\RentalAgreement" & strCustNumber)
Dim PauseTime, Start, Finish
PauseTime = 15
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Finish = Timer
Call CopytoArchiveRental
Kill "L:\Telesales\CreatedPDF\RentalAgreement" & strCustNumber & ".pdf"
Call SendNotesMail("Please find your order details attached", "L:\Telesales\CreatedPDF\Archive\RentalAgreement" & strCustNumber & ".pdf", Forms!frmMeterSales!CompanyContactEmail.Value, "", "True")
End Sub
==================

Any further assistance anyone could give, I would appreciate very much.

regards

 
Is the control that is calling the procedure on Forms!frmMeterSales![Customer Number]?

If so try changing:
strCustNumber = Forms!frmMeterSales![Customer Number]

to

strCustNumber = Me![Customer Number]
 
Hi crobg,

I tried that before and it it did not improve the results, so I'm still stuck with the same problem.

Thanks anyways

Regards
 
6. PDF gets created BUT NOT with correct Customer Number but rather with customer number from user 1. so INSTEAD of creating RentalAgreement999.pdf it creates RentalAgreement001.pdf

7. Therefore code stops after step 2 and I get an error message ".....file not found" which is understandable.
Since your function SendNotesMail appears to reference the correct file name, but the function CopytoArchiveRental does not copy the correct file name, I suggest your problem is with the function CopytoArchiveRental and not in the code you have posted.
 
Hi MoLaker,

unfortunately not the case. I'm currently working from home so had to change the filepath references hence do not use COPYTOARCHIVERENTAL and SENDNOTESMAIL.

The problem is with the code, the users lock each other somehow. In your quote from my original post, the actual data in the file refers to the correct record, but the name is still the previous one. I tried refresh, requery etc. Still no luck.

But thanks for your time and having a look.

Cheers
 
Are your using one mdb or a FE/BE model? If you are not using the FE/BE model you may start there. That way each user has their own record. Then after the transaction has completed close and re-open the form to reset the CustID field.

If you are in a FE/BE enviroment, try puting the form in data entry mode.

Let me know.
 
Hi there,

both question I can answer with YES...allow Edits, Recordsettype=Dynaset and Record Locks = Edited Records...

I read all the other threads about setting registry to PDF tool, but I guess this is not necessary, as the pdf file contains the correct data, just the name is wrong, that's why the other coding does not work. I even created a rs function that writes/overwrites the actual customer number to a table and than updates a non visible control on the form back. All works and even with two users the table has each time the correct number, just the naming of the pdf does not work.

Thanks again
 
Does the code work correctly for multiple records done by the same user?

Try setting the strCustNumber to "" (null) before assigning the current CustID of the form. Shouldn't have to though...
 
Yes, that works, as I had tried it before.

Meanwhile I have a solution. I downloaded tryout version of PDF995, took the code from their web site and now everything works as I need it.

Thanks again for your suggestion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top