Email Sending error 13 Type mismatch. (1 Viewer)

abzalali

Registered User.
Local time
Today, 20:25
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
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:25
Joined
Aug 30, 2003
Messages
36,125
A String variable can't take Null, so change that to "".
 

abzalali

Registered User.
Local time
Today, 20:25
Joined
Dec 12, 2012
Messages
118
Dear Sir,
Getting same error.

Thanks, Mir
 

Minty

AWF VIP
Local time
Today, 14:25
Joined
Jul 26, 2013
Messages
10,371
What type of control and data is stored by me.impact ? I can't see any other error
 

abzalali

Registered User.
Local time
Today, 20:25
Joined
Dec 12, 2012
Messages
118
Dear Sir,
"Me.impact" dropdown box and contain multiple select value.

Thanks
 

Minty

AWF VIP
Local time
Today, 14:25
Joined
Jul 26, 2013
Messages
10,371
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...
 

abzalali

Registered User.
Local time
Today, 20:25
Joined
Dec 12, 2012
Messages
118
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.
 

Minty

AWF VIP
Local time
Today, 14:25
Joined
Jul 26, 2013
Messages
10,371
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?
 

abzalali

Registered User.
Local time
Today, 20:25
Joined
Dec 12, 2012
Messages
118
Sorry Sir, I tried with a single value but getting same. This out my frequency.

Thanks a lot for kind cooperation.
 

abzalali

Registered User.
Local time
Today, 20:25
Joined
Dec 12, 2012
Messages
118
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
 

Minty

AWF VIP
Local time
Today, 14:25
Joined
Jul 26, 2013
Messages
10,371
Can you show us the SQL for me.impact record source, if it shows you nothing that's why its not working...
 

abzalali

Registered User.
Local time
Today, 20:25
Joined
Dec 12, 2012
Messages
118
SELECT tblImpact.Impact
FROM tblImpact
WHERE (((tblImpact.Impact) Is Not Null))
ORDER BY tblImpact.Impact;
 

Minty

AWF VIP
Local time
Today, 14:25
Joined
Jul 26, 2013
Messages
10,371
Try removing the brackets from the WHERE they don't need to be there to the best of my knowledge.
 

abzalali

Registered User.
Local time
Today, 20:25
Joined
Dec 12, 2012
Messages
118
Also same with this:
Code:
SELECT tblImpact.Impact
FROM tblImpact
ORDER BY tblImpact.Impact;
 

Minty

AWF VIP
Local time
Today, 14:25
Joined
Jul 26, 2013
Messages
10,371
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

Top Bottom