0

我在连续表格的每条记录的末尾都有一个按钮,它需要这样做:

Private Sub Update_Click()

Dim SellP As Double
Dim BuyP As Double
Dim Profit As Double

SellP = DLookup(SellPrice, Flips, [Current])
BuyP = DLookup(BuyPrice, Flips, [Current])

Profit = SellP - BuyP

Flips.Profit = Profit

End Sub

现在我知道这不是正确的代码,但我希望它能让您了解它需要做什么,基本上:

找到 SalePrice,找到 BuyPrice,从 SalePrice 中减去 BuyPrice 并得到结果 Profit,然后用利润填充 Profit 字段。

谢谢!

4

1 回答 1

2

绑定表/查询的当前记录的列在代码中直接可用。例如,如果这些字段都是绑定数据的一部分,
您可以只写 。 然后,您可以将这段代码移动到 SalePrice 和 BuyPrice 文本字段的“AfterUpdate”事件中,可能像这样: Profit = SalePrice - BuyPrice

If IsNull(salePrice) Or IsNull(buyPrice) Then
    Profit = 0
Else
    Profit = salePrice - buyPrice
End If
于 2012-10-07T14:07:54.347 回答