I have a continuous form which displays rows from a table.
I have 2 controls in particular Me.Price and Me.Gross
Price is without tax, gross is with .
If Gross is changed then the before_update does variou things and calls a sub called applychanges which effectively looks up the tax(es) for the client and recalculates Price
This all works. So I have something like (this is simplified somewhat!)
Me.Price = Me.Gross / (1 + (Me.TaxUsed.Column(2) / 100) + (Me.TaxUsed.Column(3) / 100))
Most customers have the tax included in the gross. Some however don't. So the user wants to effectively up the gross by the tax and then recalculate the price.
I have the following code, which is an event to a button on the form header, to change the Gross and I then call the sub applychanges. The gross is changed ok with the code below but the price only gets changed on the first row presumably because it's the current record. In actual fact if I move the cursor to say the 4th row before clicking the button I get a write conflict. Is this something I can't really do or am I missing something?
With rst
.MoveLast
.MoveFirst
'lngPosition = 0
Do While Not .EOF
' lngPosition = lngPosition + 1
' rst.AbsolutePosition = lngPosition
.Edit
dblGross = rst![Gross]
rst!Gross = dblGross * 1.262
.Update
.MoveNext
applychanges
Loop
.Close
End With
Set db = Nothing
Set rst = Nothing
I have 2 controls in particular Me.Price and Me.Gross
Price is without tax, gross is with .
If Gross is changed then the before_update does variou things and calls a sub called applychanges which effectively looks up the tax(es) for the client and recalculates Price
This all works. So I have something like (this is simplified somewhat!)
Me.Price = Me.Gross / (1 + (Me.TaxUsed.Column(2) / 100) + (Me.TaxUsed.Column(3) / 100))
Most customers have the tax included in the gross. Some however don't. So the user wants to effectively up the gross by the tax and then recalculate the price.
I have the following code, which is an event to a button on the form header, to change the Gross and I then call the sub applychanges. The gross is changed ok with the code below but the price only gets changed on the first row presumably because it's the current record. In actual fact if I move the cursor to say the 4th row before clicking the button I get a write conflict. Is this something I can't really do or am I missing something?
With rst
.MoveLast
.MoveFirst
'lngPosition = 0
Do While Not .EOF
' lngPosition = lngPosition + 1
' rst.AbsolutePosition = lngPosition
.Edit
dblGross = rst![Gross]
rst!Gross = dblGross * 1.262
.Update
.MoveNext
applychanges
Loop
.Close
End With
Set db = Nothing
Set rst = Nothing