L
Laurence Lombard
I realise that it is not good database method to do calculations on a form
but I would like to try it anyway for the following reasons:
1) I am familiar with Excel and VBA therefore find this method more
understandable.
2) I would like to keep my database simple - ie a form based on a Table
only.
3) other reasons which would make this post long and unwieldy.
My problem is this:
The code below updates the amount if UnitPrice or Quantity is changed. When
I am in the last record of this Form and I exit UnitPrice (using tab or
Return) a new record is generated with a zero in Quantity. How can I avoid
this happening. (note how I used IsNull to avoid an error if Quantity is
empty)
Private Sub Quantity_Exit(Cancel As Integer)
RecalculateV2
End Sub
Private Sub UnitPrice_Exit(Cancel As Integer)
RecalculateV2
End Sub
Sub RecalculateV2()
If IsNull(Me!Quantity) Then TempQuantity = 0 Else TempQuantity = Me!Quantity
Me!Netto = Me!UnitPrice * TempQuantity
End Sub
Thanks
Laurence
but I would like to try it anyway for the following reasons:
1) I am familiar with Excel and VBA therefore find this method more
understandable.
2) I would like to keep my database simple - ie a form based on a Table
only.
3) other reasons which would make this post long and unwieldy.
My problem is this:
The code below updates the amount if UnitPrice or Quantity is changed. When
I am in the last record of this Form and I exit UnitPrice (using tab or
Return) a new record is generated with a zero in Quantity. How can I avoid
this happening. (note how I used IsNull to avoid an error if Quantity is
empty)
Private Sub Quantity_Exit(Cancel As Integer)
RecalculateV2
End Sub
Private Sub UnitPrice_Exit(Cancel As Integer)
RecalculateV2
End Sub
Sub RecalculateV2()
If IsNull(Me!Quantity) Then TempQuantity = 0 Else TempQuantity = Me!Quantity
Me!Netto = Me!UnitPrice * TempQuantity
End Sub
Thanks
Laurence