Problem with VBA code

Discussion created by Nelsonucv on Jun 15, 2010
Latest reply on Jun 16, 2010 by jamesfreddyc
Guys, i've experiencing several issues with the code below, when i run the code it says "missing object", but no objects are missing, in fact this code it's a copy from another one of my project.

Apparently, the variables that i created are equal to 0 (when never it's a 0 value), those values comes from a form. May someone can help me?

Thanks in advance.

Public Sub Cal_perd_hum()
Dim pMxDoc As IMxDocument
    Dim pFeatureLayer As IFeatureLayer
    Dim pFeatureClass As IFeatureClass
    Set pMxDoc = ThisDocument
    Set pFeatureLayer = pMxDoc.FocusMap.Layer(1)
    Set pFeatureClass = pFeatureLayer.FeatureClass
    Dim pFields As IFields
    Dim ii As Integer
    Dim pQueryFilter As IQueryFilter
    Dim pCursor As ICursor
    Dim pCalc As ICalculator
    Set pFeatureLayer = pFeatureLayer
    Set pFeatureClass = pFeatureLayer.FeatureClass
    Set pFields = pFeatureClass.Fields
    Dim HL1, HL2, HL3, HL4, HL5 As Double
    Dim HG1, HG2, HG3, HG4, HG5 As Double
    Dim FM1, FM2, FM3, FM4, FM5 As Double
    'Valores del formulario de heridos leves
    HL1 = Val(FrmPerdida.txt_HL1.Text)
    HL2 = Val(FrmPerdida.txt_HL2.Text)
    HL3 = Val(FrmPerdida.txt_HL3.Text)
    HL4 = Val(FrmPerdida.txt_HL4.Text)
    HL5 = Val(FrmPerdida.txt_HL5.Text)
    'Valores del formulario de heridos graves
    HG1 = Val(FrmPerdida.txt_HG1.Text)
    HG2 = Val(FrmPerdida.txt_HG2.Text)
    HG3 = Val(FrmPerdida.txt_HG3.Text)
    HG4 = Val(FrmPerdida.txt_HG4.Text)
    HG5 = Val(FrmPerdida.txt_HG5.Text)
    'Valores del formulario de fallecidos o muertos
    FM1 = Val(FrmPerdida.txt_FM1.Text)
    FM2 = Val(FrmPerdida.txt_FM2.Text)
    FM3 = Val(FrmPerdida.txt_FM3.Text)
    FM4 = Val(FrmPerdida.txt_FM4.Text)
    FM5 = Val(FrmPerdida.txt_FM5.Text)
    '++++++++++++++++++++++++++++++Calculo del valor a tomar dependiendo del DM para las perdidas+++++++++++++++++++++++++
    'SI NO TIENE DA??O (Dm = Sin daño)
     ii = pFields.FindField("Dm")
    'Preparacion del cursor para encontrar el criterio seleccionado.
    Set pQueryFilter = New QueryFilter
    pQueryFilter.WhereClause = "Dm >= SD1 AND Dm <= SD2"
    Set pCursor = pFeatureClass.Update(pQueryFilter, True)
    ' Uso del cursor para calcular el valor.
    Set pCalc = New Calculator
    With pCalc
        Set .Cursor = pCursor
            'the error occurs here it says "Division by zero" but HL1 = 40          
              .Expression = " [Dm] * 1 / HL1"
            .Field = "Phl"
        End With

end sub