Calculating a field from same row for each row/record in form 
Author Message
 Calculating a field from same row for each row/record in form

Try this

Private Sub NewPercent_Value_LostFocus()
    dim lorst as recordset
    set lorst=me.recordsetclone

    with lorst
        .movefirst
        do until .eof
            ![SalePrice] = !Quantity * ((!EstimatedUnitCost +
((!EstimatedUnitCost) * (0.01*!NewPercent_Value))))
            .movenext
        loop
    End with
End Sub

Quote:

>I have a form based on a query in which one of the fields (SalePrice) I
want
>to do some calculating on from two other fields in the same form.  One
field
>(EstimatedCost) is in the same row/record.  The other is just a text box
>named(NewPercent).  The following code goes into an infinite loop.  If
>anyone could help me, I would greatly appreciate it.
>===========================================================================
=
>===========
>Private Sub NewPercent_Value_LostFocus()

>    For Each Row In Me

>        Me![SalePrice] = Me.Quantity * ((Me.EstimatedUnitCost +
>((Me.EstimatedUnitCost) * _(0.01*Me.NewPercent_Value))))

>    Next Row
>End Sub
>===========================================================================
=
>=============



Tue, 02 May 2000 03:00:00 GMT  
 Calculating a field from same row for each row/record in form

Try this

Private Sub NewPercent_Value_LostFocus()
    dim lorst as recordset
    set lorst=me.recordsetclone

    lorst.movefirst
    do until lorst.eof
         lorst![SalePrice] = lorst!Quantity * ((lorst!EstimatedUnitCost +
((lorst!EstimatedUnitCost) * (0.01*lorst!NewPercent_Value))))
         lorst.movenext
    loop
End Sub

Quote:

>I have a form based on a query in which one of the fields (SalePrice) I
want
>to do some calculating on from two other fields in the same form.  One
field
>(EstimatedCost) is in the same row/record.  The other is just a text box
>named(NewPercent).  The following code goes into an infinite loop.  If
>anyone could help me, I would greatly appreciate it.
>===========================================================================
=
>===========
>Private Sub NewPercent_Value_LostFocus()

>    For Each Row In Me

>        Me![SalePrice] = Me.Quantity * ((Me.EstimatedUnitCost +
>((Me.EstimatedUnitCost) * _(0.01*Me.NewPercent_Value))))

>    Next Row
>End Sub
>===========================================================================
=
>=============



Tue, 02 May 2000 03:00:00 GMT  
 Calculating a field from same row for each row/record in form

Terry,
seems you forgot .edit and .update ?

Quote:

>Try this

>Private Sub NewPercent_Value_LostFocus()
>    dim lorst as recordset
>    set lorst=me.recordsetclone

>    with lorst
>        .movefirst
>        do until .eof
>            ![SalePrice] = !Quantity * ((!EstimatedUnitCost +
>((!EstimatedUnitCost) * (0.01*!NewPercent_Value))))
>            .movenext
>        loop
>    End with
>End Sub



Tue, 02 May 2000 03:00:00 GMT  
 Calculating a field from same row for each row/record in form

Whoops,  seems your right Alex,  that'll teach me to write code off the top
of my head.

Quote:

>Terry,
>seems you forgot .edit and .update ?


>>Try this

>>Private Sub NewPercent_Value_LostFocus()
>>    dim lorst as recordset
>>    set lorst=me.recordsetclone

>>    with lorst
>>        .movefirst
>>        do until .eof
>>            ![SalePrice] = !Quantity * ((!EstimatedUnitCost +
>>((!EstimatedUnitCost) * (0.01*!NewPercent_Value))))
>>            .movenext
>>        loop
>>    End with
>>End Sub



Tue, 02 May 2000 03:00:00 GMT  
 Calculating a field from same row for each row/record in form

As has been pointed out to me I made a major typo in here

this bit

Quote:
>    do until lorst.eof
>         lorst![SalePrice] = lorst!Quantity * ((lorst!EstimatedUnitCost +
>((lorst!EstimatedUnitCost) * (0.01*lorst!NewPercent_Value))))
>         lorst.movenext
>    loop

Should read
    do until lorst.eof
        lorst.edit
        lorst![SalePrice] = lorst!Quantity * ((lorst!EstimatedUnitCost +
((lorst!EstimatedUnitCost) * (0.01*lorst!NewPercent_Value))))
        lorst.update
        lorst.movenext
    loop

Quote:

>Try this

>Private Sub NewPercent_Value_LostFocus()
>    dim lorst as recordset
>    set lorst=me.recordsetclone

>    lorst.movefirst
>    do until lorst.eof
>         lorst![SalePrice] = lorst!Quantity * ((lorst!EstimatedUnitCost +
>((lorst!EstimatedUnitCost) * (0.01*lorst!NewPercent_Value))))
>         lorst.movenext
>    loop
>End Sub


>>I have a form based on a query in which one of the fields (SalePrice) I
>want
>>to do some calculating on from two other fields in the same form.  One
>field
>>(EstimatedCost) is in the same row/record.  The other is just a text box
>>named(NewPercent).  The following code goes into an infinite loop.  If
>>anyone could help me, I would greatly appreciate it.
>>==========================================================================
=
>=
>>===========
>>Private Sub NewPercent_Value_LostFocus()

>>    For Each Row In Me

>>        Me![SalePrice] = Me.Quantity * ((Me.EstimatedUnitCost +
>>((Me.EstimatedUnitCost) * _(0.01*Me.NewPercent_Value))))

>>    Next Row
>>End Sub
>>==========================================================================
=
>=
>>=============



Wed, 03 May 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. very important!; calculating totals row by row

2. Calculating the product of row data on a single field

3. qeurying for difference in time field row to row

4. fields from different records on same row

5. Displaying field records in row

6. Selecting fields from a specific row in a continuous form

7. Calculate off of different rows?

8. Calculated rows with DBGRID

9. Calculated rows in DBGRID

10. group every 8 rows in 1 row

11. Getting row number variable from a selected row in Excel

12. adding a table row, without setting same defaults as previous row

 

 
Powered by phpBB® Forum Software