计算 Returns 零值访问 2010
Calculation Returns Zero Value Access 2010
我在 Access 2010 中有一个子项,它以数百万美元 (txtSumEstimatedValue
) 计算列的总成本,然后乘以 1,000,000 得到以美元为单位的成本 (DesignEstProgramValue
) .问题是每当更改其中一项成本时,最终成本变为 0,我不知道为什么。我试过添加 Parent.Dirty=False
但没用。
这是我正在使用的代码。
Private Sub Est_Value_AfterUpdate()
'Recalculate estimated value
Me.Recalc
Parent.[DesignEstProgramValue] = (Me.txtSumEstimatedValue) * 1000000
'Update date
Parent.[UpdatedCosts] = Date
Parent![Updated Costs].Requery
Parent!Text263.Requery
End Sub
检查这个更简单的代码版本...
Private Sub Est_Value_AfterUpdate()
Parent.[DesignEstProgramValue] = (Me.txtSumEstimatedValue) * 1000000
End Sub
Est_Value_AfterUpdate 在用户更改名为 Est_Value 的控件中的值时运行。但是在该过程中,您没有使用 Est_Value 的值。相反,您使用的是名为 txtSumEstimatedValue 的控件的值。该控件的值是多少?
通过在您的程序中包含这一行来找出答案。
MsgBox "The value of txtSumEstimatedValue is '" & Nz(Me.txtSumEstimatedValue.Value, "Null") & "'"
既然您知道 Est_Value 在 Est_Value_AfterUpdate 运行时包含正确的源值,请在您的程序:
Private Sub Est_Value_AfterUpdate()
'Parent.[DesignEstProgramValue] = (Me.txtSumEstimatedValue) * 1000000
Parent.[DesignEstProgramValue] = Me.Est_Value.Value * 1000000
End Sub
我在 Access 2010 中有一个子项,它以数百万美元 (txtSumEstimatedValue
) 计算列的总成本,然后乘以 1,000,000 得到以美元为单位的成本 (DesignEstProgramValue
) .问题是每当更改其中一项成本时,最终成本变为 0,我不知道为什么。我试过添加 Parent.Dirty=False
但没用。
这是我正在使用的代码。
Private Sub Est_Value_AfterUpdate()
'Recalculate estimated value
Me.Recalc
Parent.[DesignEstProgramValue] = (Me.txtSumEstimatedValue) * 1000000
'Update date
Parent.[UpdatedCosts] = Date
Parent![Updated Costs].Requery
Parent!Text263.Requery
End Sub
检查这个更简单的代码版本...
Private Sub Est_Value_AfterUpdate()
Parent.[DesignEstProgramValue] = (Me.txtSumEstimatedValue) * 1000000
End Sub
Est_Value_AfterUpdate 在用户更改名为 Est_Value 的控件中的值时运行。但是在该过程中,您没有使用 Est_Value 的值。相反,您使用的是名为 txtSumEstimatedValue 的控件的值。该控件的值是多少?
通过在您的程序中包含这一行来找出答案。
MsgBox "The value of txtSumEstimatedValue is '" & Nz(Me.txtSumEstimatedValue.Value, "Null") & "'"
既然您知道 Est_Value 在 Est_Value_AfterUpdate 运行时包含正确的源值,请在您的程序:
Private Sub Est_Value_AfterUpdate()
'Parent.[DesignEstProgramValue] = (Me.txtSumEstimatedValue) * 1000000
Parent.[DesignEstProgramValue] = Me.Est_Value.Value * 1000000
End Sub