run time Error : type mismatch

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sknaina
    New Member
    • Mar 2010
    • 11

    run time Error : type mismatch

    My project is based on a2003adp with sql2000 srv.
    Over there i want to control input validity check via Sp and VBA. That's why I write the following Stoted Proc as well as VBA Function and Procedure . Problem Is that when I Pass this input it prompt "type mismatch"
    I 'd not figure it out where I made a mistake , any suggestion would be highly appreciated .

    My Stored Procedure::
    Code:
    CREATE Procedure dbo.CheckBalance
    @EconomicID int,
    @CurrentBalance int,
    @CAmount int
    AS
    SET NOCOUNT ON
    BEGIN
    Declare @count bit
    set @count=0
    Select @count =isnull(count(*),0) from hdc_economict where ecoid = @EconomicID 
    and economic between cast('0010' as int) and  cast('4399' as int) 
    and economic between cast('8000' as int) and  cast('8999' as int)
    if @CAmount >@CurrentBalance and @count = 0
    begin
    return select 0
    end
    else
    begin
    return select 1
    end
    END
    GO
    Here is VBA Function
    Code:
    Private Function CheckChild() As Boolean
    Dim Valid As String
    Valid = " Exec dbo.CheckBalance " & Me.CboEconomic & ", " & Me.tXtHDC_Bal & "," & Me.TxtCodeAmount
    If Me.tXtHDC_Bal <> 0 And Valid = 0 Then
        MsgBox " Insufficient Budget amount", vbInformation, "information"
            Me.TxtCodeAmount.SetFocus
            CheckChild = False
    Else
        CheckChild = True
        End If
    End Function
    Procedure to Call this Function

    Code:
    Private Sub txtCodeAmount_AfterUpdate()
    'On Error GoTo err:
    If CheckChild = False Then
    Exit Sub
        Else
    If MsgBox(" add another transaction ? ", vbYesNo, "Confirmation") = vbNo Then Exit Sub
    If HDC_BillChildSave = True Then
    MsgBox" Data Saved", vbInformation, "Information"
    Else
    MsgBox" Data Not Save", vbInformation, "Information"
    End If
    Exit Sub
    End If
    'err:
    'MsgBox err.Description, vbCritical, "Error"
    'Exit Sub
    End Sub

    <>>>>>>>>Naina< >>>>>>>>>>>
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Hi Naina

    The first thing you should check is the data type of ecoid. If this is an autonumber created by Access it will be type Long not type Integer.

    Mary

    Comment

    • sknaina
      New Member
      • Mar 2010
      • 11

      #3
      Originally posted by msquared
      Hi Naina

      The first thing you should check is the data type of ecoid. If this is an autonumber created by Access it will be type Long not type Integer.

      Mary
      Hi ,Thanks for your reply
      yes Ecoid is a autonumber field. would you please Suggest me about this code.
      Code:
      Valid = " Exec dbo.CheckBalance " & Me.CboEconomic & ", " & Me.tXtHDC_Bal & "," & Me.TxtCodeAmount
      is it a correct syntax for holding the variable value.

      Comment

      Working...