Run-time error '13' Type mismatch

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Drahy
    New Member
    • Jun 2012
    • 4

    #1

    Run-time error '13' Type mismatch

    Hello

    I have difficulty in solving the run time error 13 type mismatch. I do not know how to solve it.
    If i write this code "JOR_No.Val ue = Right(List225.I temData(icount) , 4) + 1". The error will appear.
    If i remove " + 1" in the code, no error will shown and the whole code works normal.
    Can anyone review my codes.

    Please see attachment

    Thanks
    Attached Files
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    You are trying to numericaly add a value to a string.
    http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
    You will need to pull the information from the list, convert the string to a numeric and then do the math. Once you have the desired result, convert back to a string if needed.

    -z

    (OP's orignal code with some minor formatting)
    Error happens at line 29
    Code:
    Private Sub Job_Class_n_AfterUpdate()
    Dim icount As Integer
    Dim strgsql As String
    If Job_Class_n.Value = "Electrical" Then
      List238.Visible = False
      List225.Visible = True
      strgsql = "SELECT JOR.[JOR No], JOR.ID, " & _ 
        "JOR.[Req'g Dep't], JOR.[Machine Ident'n], " & _
        "JOR.DateR, JOR.[JOR Remarks], " & _
        "JOR.[Job Class'n], " & _
        "JOR.Category, JOR.[Description of Request], 
        "JOR.Remarks " & _
        "FROM JOR " & _
        "WHERE (((JOR.[JOB Class'n]) = 'Electrical')) " & _
        "ORDER BY JOR.[JOR No];"
      With List225
        .RowSourceType = "Table/Query"
        .RowSource = strgsql
        .ColumnCount = 10
        .ColmnWidths = ".7in;.35in;.6in;.7in; " & _
            ".65in;.65in;.6in;.6in;3in"
        .ColumnHeads = True
        .FontSize = 8
        .Requery
      End With
      Label226.Caption = "Electrical"
      For icount = 0 To (List225.ListCount - 1)
        List225.Selected(icount) = True
        JOR_No.Value = Right(List225.ItemData(icount), 4) + 1
      Next icount
    End if
    End Sub
    Last edited by zmbd; Jul 31 '12, 06:20 AM. Reason: Reformated the code block... looked better in the orginal... sigh

    Comment

    • Drahy
      New Member
      • Jun 2012
      • 4

      #3
      Thanks for your advised
      Its working.
      I already converted the data in numerical value
      before i add the data
      I reformat my code block based on your suggestion
      It is big help for me.

      Thank you very much

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Is the question answered?

        Originally posted by Drahy
        Thanks for your advised
        Its working.
        I already converted the data in numerical value
        before i add the data
        I reformat my code block based on your suggestion
        It is big help for me.

        Thank you very much
        Glad to be of help... if this has answered your question would you please click on the [Choose as best Answer] button...

        Thnx
        Z

        Comment

        Working...