i am using this function to calculate dim1 on the afterupdate event of a combobox which is material.
the list of the material combobox and the formula are in one linked table.
the problem is that the dim1 is updated with only the first entry of the formula values in the table no matter wat i choose from the combobox list.
i just need the dim1 to be updated with the correspondant formula to the material chosen in the combobox.(formula corresponding to the same row of the material)
Private Sub Material_AfterUpdate()
dim1 = getExposure(Form_Products.size1p.Value, Form_Products.size2p.Value, Form_subtypes.Formula)
End Sub
Public Function getExposure(x, y, z) As Variant
Do While InStr(z, "Valx") > 0
z = Left(z, InStr(z, "Valx") - 1) & Trim(Str(x)) & Mid(z, InStr(z, "Valx") + 4)
Loop
Do While InStr(z, "Valy") > 0
z = Left(z, InStr(z, "Valy") - 1) & Trim(Str
) & Mid(z, InStr(z, "Valy") + 4)
Loop
getExposure = Eval(z)
End Function
the list of the material combobox and the formula are in one linked table.
the problem is that the dim1 is updated with only the first entry of the formula values in the table no matter wat i choose from the combobox list.
i just need the dim1 to be updated with the correspondant formula to the material chosen in the combobox.(formula corresponding to the same row of the material)

Private Sub Material_AfterUpdate()
dim1 = getExposure(Form_Products.size1p.Value, Form_Products.size2p.Value, Form_subtypes.Formula)
End Sub
Public Function getExposure(x, y, z) As Variant
Do While InStr(z, "Valx") > 0
z = Left(z, InStr(z, "Valx") - 1) & Trim(Str(x)) & Mid(z, InStr(z, "Valx") + 4)
Loop
Do While InStr(z, "Valy") > 0
z = Left(z, InStr(z, "Valy") - 1) & Trim(Str

Loop
getExposure = Eval(z)
End Function