Results 1 to 8 of 8

Thread: Run Time Error 13 Type MisMatch

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    688

    Run Time Error 13 Type MisMatch

    Hi

    In the below code it is giving me the above error

    Private Sub lvwitem_ItemClick(ByVal Item As MSComctlLib.ListItem)
    Dim strItemKey As String
    Dim strId As String

    strItemKey = Item.Key
    strId = Mid(strItemKey, 2)

    If rstitem.RecordCount > 0 Then
    rstitem.MoveFirst
    End If
    rstitem.Find ("icode = '" & Trim(strId) & "'")
    If Not rstitem.EOF Then
    Set ItmFound = lvwitem.FindItem(strId, 0, , 0)

    End If
    end sub

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Run Time Error 13 Type MisMatch

    Which line?
    What is ItmFound?
    Are you using Option Explicit?

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Run Time Error 13 Type MisMatch

    Also, it should be rstitem.findItem......if I recall correctly.

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Run Time Error 13 Type MisMatch

    RSTItem is apparently a Recordset so Find would be correct.

    OP needs to show which line the error occurs on and also needs to start using code tags when posting code

    My guess is that the error is on this line
    Set ItmFound = lvwitem.FindItem(strId, 0, , 0)

    Note that ItmFound is not defined in the code shown so we have no idea if it is properly dimmed as a ListItem

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Run Time Error 13 Type MisMatch

    I also have no idea what the purpose of that code is.

    It is passed a listitem and then it searches the list for that list item and returns nothing?

    If you already know the listitem, why search the listview for that listitem? Is it coming from a different listview?

  6. #6
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Run Time Error 13 Type MisMatch

    Oh yeah.....I read it to fast....thought his rstitem was the LISTVIEW.....duh!

  7. #7
    Addicted Member
    Join Date
    Jul 2014
    Posts
    176

    Re: Run Time Error 13 Type MisMatch

    Code:
    Set ItmFound = lvwitem.FindItem(strId, 0, , 0)
    I think your error lies in this part...

    Check the DATA TYPE or how you DECLARED your ItmFound...

    I think this is INTEGER, and your strid is passing a NULL STRING.

    Which causes the MISMATCH.
    Last edited by terry002; Oct 16th, 2014 at 10:23 PM.
    If I had helped you...

    Don't forget to mark your Inquiry as RESOLVED...

    I will be glad if you can also give me some Reputation points in helping you (by Clicking Rate This Post)...

    Happy VB Coding Everyone!

  8. #8
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Run Time Error 13 Type MisMatch

    Tend to agree with terry002....what IS ItmFound declared as?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width