can anybody tell me why i am getting type mismatch error in checkinput function.Here is the code what i have written.error
is generatiing from bold line.

Private Function CheckInput() As Boolean
  Dim row As Integer, itemCode() As Integer
 'At first always Test for Empty TextBoxes
  If Combo1.Text = "Dept NO" Then
    MsgBox "there value needed for department", vbInformation, Me.Name
    Exit Function
  End If
  If IsEmpty(TxtJobNo.Text) Then
       MsgBox "it cannnot be blank"
       TxtJobNo.SetFocus
       Exit Function
  End If
  If TxtDep_ID.Text = "" Then
     MsgBox "there is a value needed for cost centre", vbInformation, Me.Name
     TxtDep_ID.SetFocus
     Exit Function
  End If
'now we test for Numeric
  If Not IsNumeric(TxtDep_ID.Text) Then
     MsgBox "there value for the cost centre needs to be numeric"
' Kill the wrong input
     TxtDep_ID.Text = ""
     TxtDep_ID.SetFocus
     Exit Function
  End If
  If TxtJobNo.Text = "" Then
   MsgBox "there is a value needed for job no", vbInformation, Me.Name
   TxtJobNo.SetFocus
   Exit Function
  End If
  If TxtRequBy.Text = "" Then
    MsgBox "there is a value needed for Requested by", vbInformation, Me.Name
    TxtRequBy.SetFocus
    Exit Function
  End If
  If TxtDel_Point.Text = "" Then
  MsgBox "there is a value needed for delivery point", vbInformation, Me.Name
    TxtDel_Point.SetFocus
   End If
  If Not IsDate(DTPicker1.Value) Then
  MsgBox "there value for the date need to be date"
  DTPicker1.Value = True
  End If
  
  If Not IsDate(DTPicker2.Value) Then
  MsgBox "there value for the date need to be date"
  DTPicker2.Value = True
  End If
  If TxtSugSupplier.Text = "" Then
    MsgBox "suggested vendor cannot be blank", vbInformation, Me.Name
    TxtSugSupplier.SetFocus
    Exit Function
    End If
 If Not IsDate(MaskEdBox1.Text) Then
 MsgBox "the Time format is wrong", vbInformation, Me.Name
 MaskEdBox1.SetFocus
 Exit Function
 End If
 If IsEmpty(MaskEdBox1.Text) Then
 TxtJobNo.SetFocus
 MsgBox "it cannot be blank", vbInformation, Me.Name
 Exit Function
 End If
' are there any Gridrows existing
If (Grd.Rows < 2) Then
  MsgBox "You havn't entered any Materials to request", vbInformation, Me.Name
  Exit Function
Else
 ' we build a controlarray for the used Item_code's
  ReDim itemCode(Grd.Rows) As Integer
  For row = 1 To Grd.Rows - 1
    If (Not Grd.TextMatrix(CLng(row), 1) = "") Then
        If Grd.TextMatrix(CLng(row), 4) = "" Then
           MsgBox "You need to finish your entries in the grid first by pressing 'Enter'", vbInformation, Me.Name
           Exit Function
        Else
           ' Check if the itemcode already exists
           For i = 1 To row
             [B] If itemCode(i) = Grd.TextMatrix(CLng(row), 1) Then[/B]                 Call MsgBox("You are not allowed to have the same item twice in your list. Please add them up so each item is there only once.")
                 Exit Function
              End If
           Next
           ' it isn't here so we add it to our compare array
           itemCode(row) = Grd.TextMatrix(CLng(row), 1)
        End If
    End If
   
  Next
End If

' If Not isstr(Combo1.Text) Then
'  MsgBox "Please enter/select a Text in COMBO"
'  Exit Function
' End If

' now we test all other Textboxes DateTime Pickers ... whatever
' In the end of this tests we will only reach this point if all was OK
' because in any other case we are leaving with exit
CheckInput = True
End Function

Only a guess, but it looks like you may be comparing an integer with a string. Set a breakpoint on or just before line in question, then user cursor to hover over each value to be evaluated, or use debug window, and check to see if itemcode(i) actually has a value and if Grd.TextMatrix(CLng(row), 1) is returning a string. i.e. "1"

Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.