Private Sub cmdEmail_Click()
Dim strTo As String
Dim strSubject As String
Dim strMessageText As String
Me.Dirty = False
strTo = [Order Details subform].[Form]![EMailaddress]
strSubject = " Acknowledgement Number " & Me.orderID
strMessageText = Me.Firstname & "," & _
vbNewLine & vbNewLine & _
"Your latest Acknowledgement is attached." & _
vbNewLine & vbNewLine & _
""
DoCmd.SendObject ObjectType:=acSendReport, _
ObjectName:="order acknowledgement", _
OutputFormat:=acFormatPDF, _
TO:=strTo, _
Subject:=strSubject, _
messageText:=strMessageText, _
EditMessage:=True
End Sub
Private Sub cmdOpenInvoice_Click()
On Error GoTo Err_Handler
Const MESSAGE_TEXT = "No current ack number."
If Not IsNull(Me.orderID) Then
' ensure current record is saved
Me.Dirty = False
' open report in print preview
DoCmd.OpenReport "order acknowledgement", View:=acViewPreview
Else
MsgBox MESSAGE_TEXT, vbExclamation, "Invalid Operation"
End If
Exit_Here:
Exit Sub
Err_Handler:
MsgBox Err.Description
Resume Exit_Here
End Sub
Private Sub cmdPDF_Click()
On Error GoTo Err_Handler
Const FOLDER_EXISTS = 75
Const MESSAGE_TEXT1 = "No current invoice."
Const MESSAGE_TEXT2 = "No folder set for storing PDF files."
Dim strFullPath As String
Dim varfolder As Variant
If Not IsNull(Me.orderID) Then
varfolder = DLookup("Folderpath", "pdfFolder")
If IsNull(varfolder) Then
MsgBox MESSAGE_TEXT2, vbExclamation, "Invalid Operation"
Else
' create folder if does not exist
varfolder = varfolder & "\" & Year(date) & "\" & [Order Details subform]![CustomerName] & "\" & "NCO" & Format(Me.NCO_No, "0000")
Call subUNCFolder(varfolder)
'strFullPath = varFolder & "\" & ME.CustomerName & " " & Me.Invoicenumber & ".pdf"
strFullPath = varfolder & "\" & "NCO Number " & " " & Me.NCO_No & ".pdf"
' ensure current record is saved before creating PDF file
Me.Dirty = False
DoCmd.OutputTo acOutputReport, "order acknowledgement", acFormatPDF, strFullPath
End If
Else
MsgBox MESSAGE_TEXT1, vbExclamation, "Invalid Operation"
End If
'End If
Exit_Here:
Exit Sub
Err_Handler:
Select Case Err.Number
Case FOLDER_EXISTS
Resume Next
Case Else
MsgBox Err.Description
Resume Exit_Here
End Select
End Sub