Results 1 to 6 of 6
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670

    Type Mismatch Error

    Hi - I am using the afterupdate() event of a combo box with this query



    Code:
    Dim info As String
    info = “Select [CN] & “ - “ & [AF] As Info “ & _
             “From [_Data] “ & _
             “Where supname = ‘“ & Me.cboTest.Column(0) & ‘“;”
    But at runtime I get this error

    Run time error ‘13’
    Type mismatch

  2. #2
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    Your quotes at the end are all out of sync - try this;
    Code:
    Dim info as String
    
    info = "Select [CN] & '-' & [AF] As Info " & _
             "From [_Data] " & _
             "Where supname = '" & Me.cboTest.Column(0) & "';"
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Are those quote characters what you're really using? I have seen them cause this or similar issues (they get copied from some web code somehow). Access doesn't like them. If you're trying to build sql string, maybe more like

    info = "Select [CN] & " - " & [AF] & " As Info From [_Data] Where supname = '" & Me.cboTest.Column(0) & ';"
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670
    Ah - it was the double quotes I used around the - changing that to single quotes resolved.

    And no those were not the actual quotes I was using. I posted from mobile so was unable to do a straight copy/paste

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    either syntax should work. FWIW the ending semicolon isn't needed in vba.

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Code:
    Dim info As String
    info = “Select [CN] & “ - “ & [AF] As Info From [_Data] Where supname = ‘“ & Me.cboTest.Column(0) & ‘“;”
    I would debug.print your 'info' value I bet it doesn't work.

    Code:
    info = "SELECT [CN] & "" - "" & [AF] As INFO FROM [_Data] WHERE Supname = '" & me.cbotest.column(0) & "'"
    This is assuming your table is actually named _DATA and the field is actually named SUPNAME

    If you are enclosing " marks within a string you have to double them up "" which is what I did around your hyphen.

    At the end of your statement you are inverting your " and ' marks as well which you can also solve by putting "" marks anywhere there is a ' mark

    So your original statement (when I put in spaces to make it more visible is

    Code:
    ...SUPNAME = ' " & me.cbotest.column(0) & ' ".....
    the single quote on the right is on the wrong side of the " mark

    Code:
    ...SUPNAME = ' " & me.cbotest.column(0) & " '.....

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

Similar Threads

  1. Type 13 (Type Mismatch) error
    By sdel_nevo in forum Programming
    Replies: 5
    Last Post: 01-22-2016, 10:01 AM
  2. Type Mismatch Error
    By thexxvi in forum Access
    Replies: 3
    Last Post: 11-10-2015, 10:11 AM
  3. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  4. Replies: 1
    Last Post: 05-11-2012, 10:59 AM
  5. Error#13 Type Mismatch
    By Nistin27 in forum Access
    Replies: 8
    Last Post: 08-17-2011, 04:15 PM

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