Hi,
The problem is a bit strange. On a form I have a combobox cmbZP and 4 text boxes: zp, inpZP, M and MT. The data source for the combobox is a small table with 2 columns: ID and text, containing exacly 4 records.
Depending on the choice in the combobox, the form performs different calculations. In order to enable the code I have a button with the VBA code attached to it. Here is the code:
Code:
Function calculate()
Select Case cmbZP.ListIndex
Case Is = 1
Me.zp.Value = Me.inpZP.Value
Case Is = 2
Me.zp.Value = (Me.inpZP.Value * ((100 - Me.M.Value) / (100 - Me.MT.Value)))
Case Is = 3
Me.zp.Value = (Me.inpZP.Value * ((100 - Me.M.Value) / 100))
Case Is = 4
Me.zp.Value = (Me.inpZP.Value * (((100 - (Me.M.Value + Me.zp.Value)) / 100)))
Case Else
Me.zp.Value = Me.inpZP.Value
End Select
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name
End Function
The problem is that when I pick the second entry from the combobox, the form saves data, however does not preform the calculation, thus it acts as if I would pick the first entry. Any idea what may be wrong?
Thanks in advance
Regards