Database problem

CosmaL

Registered User.
Local time
Today, 11:23
Joined
Jan 14, 2010
Messages
94
Hello my friends!

In my database (in a server with the appropriate user control, (single database file, not splitted), i got a sub which exports a report as a pdf and then creates an email with the report and another excel file (total 2 attachements).

My problem is that in my computer (win 10, office 2013) it's working fine.
When i run the database on another computer (win 10, office 2016 without access, we use access environment 2013), when i run the sub i got the error 2501, path doesn't exist. Looking in the folder, the report has been created but then i got the error.

Both users have the same access in the database folder/subfolders.

Below is the code:

Private Sub Command75_Click()
On Error GoTo Err_Command75_Click

Dim MailRecipientTemp, MailSubject, Respo As String
Dim MailRecipient, ccResipient As String
Dim CustomerT, TypeT, CustomerD, TypeD As String
Dim stDocName As String
Dim objOutlook As Object
Dim objEmail As Object
Dim todayDate, filename, filename1 As String
Dim strBody As String
Dim strEmail, strEmailCC As String
Dim strSubject As String
Dim strPathAttach, strPathAttach1 As String

Const olMailItem As Integer = 0

Set objOutlook = CreateObject("Outlook.Application")
Set objEmail = objOutlook.CreateItem(olMailItem)

stDocName = "RespoIncomeSampleDate"

todayDate = Format(Date, "DDMMYYYY")

filename = "c:\temp\Customer Samples\PDF" & "" & stDocName & "_" & todayDate & ".pdf"

DoCmd.OutputTo acReport, stDocName, acFormatPDF, filename, False

filename1 = "c:\temp\Customer Samples\SampleAnalysisRequest.xlsx"

MailRecipientTemp = Me.[Responsible person]


Select Case MailRecipientTemp
'Select users for mail
End Select


MailSubject = "Report"

strEmail = MailRecipient
strSubject = MailSubject
strBody = "Dear " & Respo & vbCrLf & vbCrLf & "Attached you may find the report for the new sample(s), along with the 'sample analysis request form', which you are kindly requested to complete and return it back to me." & vbCrLf & "Best Regards,"
strPathAttach = filename
strPathAttach1 = filename1

objEmail.To = strEmail
objEmail.cc = ccResipient
objEmail.Subject = strSubject
objEmail.Body = strBody

With objEmail.Attachments
'use parenthisis around the path
.Add (strPathAttach)
.Add (strPathAttach1)
End With


objEmail.Display


Set objOutlook = Nothing
Set objMailItem = Nothing

Exit_Command75_Click:
Set objOutlook = Nothing
Exit Sub

Err_Command75_Click:
MsgBox Err & ": " & Err.Description
Resume Exit_Command75_Click
End Sub

Any ideas?

Thanks!!!!!!
 
see your "filename" variable.
you are missing one backslash (\).
should be:

filename="c:\temp\Customer Samples\PDF\" & stDocName & "_" & todayDate & ".pdf"
 
I've corrected it but i still get the message.

When i compile it, i don't get any errors in the code.

Should there be any mulfuction between the office versions?
 
Most times for development I'll try early binding first, then switch to late binding for testing/distribution. Perhaps you could try that (add a reference to Outlook and change your Object types to their appropriate strong types, develop and test it all, then change back to Object).

Also, just to be sure: you do have Option Explicit at the top of this (and all) modules?
 
Are you sure the path actually exist at the problem computer?
 
on this part:

objEmail.To = strMail
objEmail.cc = ccResipient
objEmail.Subject = strSubject
objEmail.body = strBody


check objEmail.cc, do you have the variable ccResipient?
 
The report might have been created, but does this exist?
Code:
filename1 = "c:\temp\Customer Samples\SampleAnalysisRequest.xlsx"
 
Hello,

problem solved. For a reason it stopped in this part: strPathAttach1 = filename1
I changed to "manual" strPathAttach1 = "c:\temp\Customer Samples\SampleAnalysisRequest.xlsx" and it worked.

jleach: Option explicit was "missing", added in the top of the module.
JHB: I've created the path before running the database
arnelgp: variable ccResipient, is ok, there was a typing error and i kept it that way (i use only in this module).
Gasman: Both files exist.

Thank you all for your help!!!!
 
Only for info:
Code:
Dim MailRecipientTemp, MailSubject, Respo As String
Only the Respo is declared as string, the rest is Variant type.
You've to assign the type after each variable, like below.
Code:
Dim MailRecipientTemp [COLOR=Red]As String, [/COLOR]MailSubject [COLOR=red]As String[/COLOR], Respo As String
 
I will correct it, i have the same way of declarations in 2-3 modules.

Thnaks!!!
 

Users who are viewing this thread

Back
Top Bottom