Results 1 to 6 of 6
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Why am I getting a type mismatch error


    In the file attached the line shown in the pdf file shows a type mismatch. I am unsure as to why I getting the error.

    The variable strWho is declared as a string. The name it is associated with is just that. So why the type mismatch error?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  2. #2
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Wait, what type of variable is EmployeeName(1)? I thought it was a string. That should make cboEmployeeName(1) a string.

    Any way what kind of variable is it.

    Respectfully,

    Lou Reed

  3. #3
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Don't see the declaration for strWho in your pdf.

    I suspect you cannot compile the database without it giving you an error on that line or any other line that is bad...

    The proper syntax is: strWho = Me.cboEmployeeName.Column(1)

    But why do that? Instead dump the variable strWho and:
    strWhere = "[qryPersonnelMetting2].[emailaddress] = '" & Me.cboEmployeeName.Column(1) & "'"

    I'm thinking we have reviewed this same code before...

  4. #4
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    This code has been reviewed before. It is just being changed now because of modifications in the relationships.

    Thanks very much for your input.

    I always try to use Options Explicit at the top of all of my code. If it is not there I will put it in.

    I seem to have this problem in that I set Option Explicit an I assume that will always remain at the top of my code.

    It does not stay, sometimes.

    Again, I will check this out.

    Thank you very much.

    Respectfully,

    Lou Reed

  5. #5
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I looked at your suggestions and I am now confused. I did have Option Explicit at the top of this code. The term strWho is declared.

    Your statement :

    Code:
    The proper syntax is: strWho = Me.cboEmployeeName.Column(1)


    is exactly what I used.

    The code does compile. but when it gets to the line:

    strWho = Me.cboEmployeeName.Column(1)

    I get a type mismatch error.

    What is going on, why a I getting a type mismatch error?

    Please explain how I can simplify or reduce this code to something simpler.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed



  6. #6
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    The code in your provided database indeed has the line I advised you to correct:
    Code:
        Dim strWhere As String       '--Criteria for DLookup
        Dim varTO As Variant         '--Address for SendObject
        Dim strText As String        '--E-mail text
        Dim RecDate As Variant       '--Rec date for e-mail text
        Dim strSubject As String     '--Subject line of email
        Dim strWho As String         '--Reference to tblPersonnel
        Dim strBranchhead As String  '--Branchhead making meeting invite
        Dim strSQL As String         '--Create SQL update statement
        Dim strMeetingID As String
        Dim errLoop As Error
        
        '-- Combo of name to send email to
        strWho = Me.cboEmployeeName(1)
        strWhere = "[qryPersonnelMeeting2].[emailaddress] = " & "'" & strWho & "'"
        '--Looks up email address from Personnel Meeting Query
        varTO = Me.cboEmployeeName
        
        strSubject = ":: Meeting Invitation ::"
        RecDate = Me.txtMeetingDate
        strMeetingID = Me.txtMeetingID
        '--Branchhead who emails invitation
        strBranchhead = Me.cboEmployeeName
    Go back to my post #3 and make the code corrections. Then you will no longer get Error 13 Type mismatch.

    I didn't suggest you add Option Explicit - it is already there.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA SQL Error 13 Type Mismatch
    By Larryg in forum Queries
    Replies: 11
    Last Post: 11-28-2016, 05:11 PM
  2. Type 13 (Type Mismatch) error
    By sdel_nevo in forum Programming
    Replies: 5
    Last Post: 01-22-2016, 10:01 AM
  3. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  4. type mismatch error 13
    By Compufreak in forum Access
    Replies: 3
    Last Post: 08-10-2012, 03:48 AM
  5. Replies: 1
    Last Post: 05-11-2012, 10:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums