Hello all,
I know what is causing my issue but don't know how to fix it. I'm sure someone can point me in the right direction....
I have a button on a form that outputs a report to pdf, saves in a specified folder, then attaches it to an email. It's worked perfectly until I had the need modify the OnLoad event for the report to hide or display two labels based on a text box on the report.
It looks like output to pdf doesn't run the code on the report, so the pdf displays both labels, one on top of the other.
Here's the code on the OnLoad event for the report.
Here is the piece of code that saves pdf and sends email...
So, how do I get the desired report output?
Thanks in advance for your help!
I know what is causing my issue but don't know how to fix it. I'm sure someone can point me in the right direction....
I have a button on a form that outputs a report to pdf, saves in a specified folder, then attaches it to an email. It's worked perfectly until I had the need modify the OnLoad event for the report to hide or display two labels based on a text box on the report.
It looks like output to pdf doesn't run the code on the report, so the pdf displays both labels, one on top of the other.
Here's the code on the OnLoad event for the report.
Code:
Private Sub Report_Load()
'ck Advertiser and modify accordingly
Dim Advertiser
Dim Contact
Dim CPCName
Dim CPCPhone
Advertiser = Me.txtBCompanyID
Contact = Me.txtBContactID
CPCName = Me.txtCPCName
CPCPhone = Me.txtCPCPhone
If Advertiser = 463 Then
CPCName = DLookup("ContactName", "tblContacts", "Contact_ID = " & Contact)
CPCPhone = DLookup("OtherPhone", "tblContacts", "Contact_ID = " & Contact)
Debug.Print CPCName
Debug.Print CPCPhone
With Me
.txtCPCName = CPCName
.txtCPCPhone = CPCPhone
.lblTTTNotes.Visible = True
.lblOtherNotes.Visible = False
End With
Else
With Me
.txtCPCName = ""
.txtCPCPhone = ""
.lblTTTNotes.Visible = False
.lblOtherNotes.Visible = True
End With
End If
End Sub
Here is the piece of code that saves pdf and sends email...
Code:
strUserName = Environ("Username")
strFileName = Me.txtFileName
Me.txtFileName.Requery
strFilePath = "C:\Users\" & strUserName & "\OneDrive - xxx\xxx\xxx\xxx\" & IOYear & "\" & strFileName
Debug.Print strFilePath
'Create PDF file of IO
'Turn off system messages
DoCmd.SetWarnings False
'Output File
DoCmd.OutputTo acOutputReport, "Insertion Order Print", acFormatPDF, strFilePath
So, how do I get the desired report output?
Thanks in advance for your help!