Solved Adding surname to .pdf output (1 Viewer)

Sreemike

Registered User.
Local time
Today, 03:23
Joined
Jan 20, 2012
Messages
31
I have a form used to run a report.
I have managed to output the report in pdf form by using the following VBA:

DoCmd.OutputTo acOutputReport, "rptPrnAuto", acFormatPDF, "C:\Users\Shree\Desktop\NKToEmail\AutoAb.PDF"


But I want to replace the generic AutoAb.pdf with the Firstname and surname given in the form. So the given report pdf will be generated with the name eg: AlanSmith.pdf
That is, I want to insert the Firstname & Surname fields from the form to the name of the .pdf output.
Can anyone help me with this please?
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:23
Joined
Sep 21, 2011
Messages
14,234
It is called concatenation?
Code:
DoCmd.OutputTo acOutputReport, "rptPrnAuto", acFormatPDF, "C:\Users\Shree\Desktop\NKToEmail\" & Trim(Me.Firstname)  & Trim(Me.Surname) & ".PDF"


HTH
 

Sreemike

Registered User.
Local time
Today, 03:23
Joined
Jan 20, 2012
Messages
31
It is called concatenation?
Code:
DoCmd.OutputTo acOutputReport, "rptPrnAuto", acFormatPDF, "C:\Users\Shree\Desktop\NKToEmail\" & Trim(Me.Firstname)  & Trim(Me.Surname) & ".PDF"


HTH
Brilliant! I was missing the me.name How do I get a space or an _ between the first and surname? Thank you.
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:23
Joined
Sep 21, 2011
Messages
14,234
Brilliant! I was missing the me.name How do I get a space or an _ between the first and surname? Thank you.
Well I had a - originally, then saw that you wanted it as AlanSmith ?
So just contcatenate whatever you want into the correct place.?

Should be obvious now, I have shown you how. No need for a Trim function with that.

You might not have needed the Me., but I always use it to be clear as to what I am using, matter of habit.
 

Sreemike

Registered User.
Local time
Today, 03:23
Joined
Jan 20, 2012
Messages
31
Well I had a - originally, then saw that you wanted it as AlanSmith ?
So just contcatenate whatever you want into the correct place.?

Should be obvious now, I have shown you how. No need for a Trim function with that.

You might not have needed the Me., but I always use it to be clear as to what I am using, matter of habit.
Thank you very much.
The following code works perfect for me:
DoCmd.OutputTo acOutputReport, "rptPrnTH1TH2", acFormatPDF, "C:\Users\Shree\Desktop\NKToEmail\" & Trim(Me.Firstname) & " " & Trim(Me.Surname) & "_TH1TH2.PDF"

Many thanks.
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:23
Joined
Sep 21, 2011
Messages
14,234
You might want to think about putting the Surname first?
Easier to locate files that way, I have found?
 

Users who are viewing this thread

Top Bottom