Hello everyone,
I have a email function where to Dlookup the to: and Cc: on a table tblDivision. For some reason if cc is blank on table is not working. If data exsit works okay. I try to use if stCC = "" or Null still not working
Here is my code, works okay if stTo and stCC are not blank
~~~~~~~~~~~~~~~~~~
Private Sub cmdEmailNotification_Click()
On Error GoTo Err_cmdEmailNotification_Click
Dim Subject As String
Dim stDocName As String
Dim strWhere As String
Dim SQL As String
Dim stTo As String
Dim stCC As String
stDocName = "rptMainNotification"
Subject = "Bankruptcy " & "Case Number:" & " " & UCase(CaseNumber) & " Debtor Name:" & " " & DebtorName
stTo = DLookup("Alias", "tblDivision", "Coordinator=" & Chr(34) & Me.Copies & Chr(34))
stCC = DLookup("BAlias", "tblDivision", "Coordinator=" & Chr(34) & Me.Copies & Chr(34))
'Display only current selected ID
strWhere = "[ID]=" & Me!ID
'Update Email Date Sent field
DoCmd.SetWarnings (False)
SQL = "UPDATE maintblBankruptcy SET DateESent = Date()" & _
"WHERE Relationship = '" & Me.Relationship & "'"
'DateESent is Null AND
DoCmd.RunSQL SQL
DoCmd.OpenReport stDocName, acPreview, , strWhere, acHidden
If stCC = "" Then
DoCmd.SendObject acSendReport, stDocName, "Snapshot Format", stTo, , , Subject, "Bankruptcy Notification, open attachment"
Else
DoCmd.SendObject acSendReport, stDocName, "Snapshot Format", stTo, stCC, , Subject, "Bankruptcy Notification, open attachment"
End If
DoCmd.Close acReport, stDocName
Exit_cmdEmailNotification_Click:
Exit Sub
Err_cmdEmailNotification_Click:
Resume Exit_cmdEmailNotification_Click
End Sub
I have a email function where to Dlookup the to: and Cc: on a table tblDivision. For some reason if cc is blank on table is not working. If data exsit works okay. I try to use if stCC = "" or Null still not working
Here is my code, works okay if stTo and stCC are not blank
~~~~~~~~~~~~~~~~~~
Private Sub cmdEmailNotification_Click()
On Error GoTo Err_cmdEmailNotification_Click
Dim Subject As String
Dim stDocName As String
Dim strWhere As String
Dim SQL As String
Dim stTo As String
Dim stCC As String
stDocName = "rptMainNotification"
Subject = "Bankruptcy " & "Case Number:" & " " & UCase(CaseNumber) & " Debtor Name:" & " " & DebtorName
stTo = DLookup("Alias", "tblDivision", "Coordinator=" & Chr(34) & Me.Copies & Chr(34))
stCC = DLookup("BAlias", "tblDivision", "Coordinator=" & Chr(34) & Me.Copies & Chr(34))
'Display only current selected ID
strWhere = "[ID]=" & Me!ID
'Update Email Date Sent field
DoCmd.SetWarnings (False)
SQL = "UPDATE maintblBankruptcy SET DateESent = Date()" & _
"WHERE Relationship = '" & Me.Relationship & "'"
'DateESent is Null AND
DoCmd.RunSQL SQL
DoCmd.OpenReport stDocName, acPreview, , strWhere, acHidden
If stCC = "" Then
DoCmd.SendObject acSendReport, stDocName, "Snapshot Format", stTo, , , Subject, "Bankruptcy Notification, open attachment"
Else
DoCmd.SendObject acSendReport, stDocName, "Snapshot Format", stTo, stCC, , Subject, "Bankruptcy Notification, open attachment"
End If
DoCmd.Close acReport, stDocName
Exit_cmdEmailNotification_Click:
Exit Sub
Err_cmdEmailNotification_Click:
Resume Exit_cmdEmailNotification_Click
End Sub