Email Sending error 13 Type mismatch.

abzalali

Registered User.
Local time
Today, 23:20
Joined
Dec 12, 2012
Messages
118
Dear Expert,
I'm trying to set email address for "Cc" using "Like" but showing error 13 Type mismatch. Problem only red mark code either all are working fine. please help me.
Code:
Private Sub cmdSendMail_Click()
On Error GoTo ErrorHandler
    Dim strTo As String
    Dim strSubject As String
    Dim strMessageText As String
    Dim strReport As String
    Dim strAttachmentName As String
    Dim strWhere As String
    
    Me.Dirty = False
    
    strTo = ""
    strSubject = "ECN " & Me.JobStructure
    strMessageText = " "
    strReport = "rptECN"
    strAttachmentName = "ECN " & Me.JobStructure
    
  [COLOR=Red]  If Me.Impact Like "*Purchasing*" Then
       strWhere = "purchasing@gmail.com"
    Else
       strWhere = Null
    End If[/COLOR]
        
    DoCmd.OpenReport strReport, acViewPreview, , , acHidden
    Reports(strReport).Caption = strAttachmentName
    DoCmd.SendObject ObjectType:=acSendReport, _
        ObjectName:=strReport, _
        OutputFormat:=acFormatPDF, _
        To:=strTo, _
        Cc:=strWhere, _
        Subject:=strSubject, _
        MESSAGETEXT:=strMessageText, _
        EditMessage:=True
    DoCmd.Close acReport, strReport
    MsgBox "Message Sent Successfully."

Cleanup:
  Exit Sub

ErrorHandler:
  Select Case Err.Number
    Case 2501
      MsgBox "Email message was Cancelled."
    Case Else
      MsgBox Err.Number & ": " & Err.Description
  End Select
  Resume Cleanup
    
End Sub
 
A String variable can't take Null, so change that to "".
 
Dear Sir,
Getting same error.

Thanks, Mir
 
What type of control and data is stored by me.impact ? I can't see any other error
 
Dear Sir,
"Me.impact" dropdown box and contain multiple select value.

Thanks
 
So what type of data is the bound column of your combo box?
I suspect its the ID field which is numeric and you are trying to compare a string...
 
Sir,
Of course the table contain two field ID, IMPACT but in dropdown box I just call only IMPACT filed not ID, and there are bound column and count column also 1.

When select multiple record then it shows one next one by comma separator.
 
if you have a list box with multi select enabled the string you are comparing will be similar to

"value1, value2" I'm pretty sure you would not be able to do a sting compare with a comma separated list like that. Try limiting it to a single value and see if that works?
 
Sorry Sir, I tried with a single value but getting same. This out my frequency.

Thanks a lot for kind cooperation.
 
debug.print me.impact it shows nothing that mean blank. But other current form field print in immediate window.

Still I see data in the impact filed on form
 
Can you show us the SQL for me.impact record source, if it shows you nothing that's why its not working...
 
SELECT tblImpact.Impact
FROM tblImpact
WHERE (((tblImpact.Impact) Is Not Null))
ORDER BY tblImpact.Impact;
 
Try removing the brackets from the WHERE they don't need to be there to the best of my knowledge.
 
Also same with this:
Code:
SELECT tblImpact.Impact
FROM tblImpact
ORDER BY tblImpact.Impact;
 
debug.print me.impact it shows nothing that mean blank. But other current form field print in immediate window.

Still I see data in the impact filed on form
This is the crux of your problem - have you resolved this yet? Can you post a stripped down version of your database to let us have a look?
 

Users who are viewing this thread

Back
Top Bottom