Conditional running sum

K

Kon

How can I use the bellow code using conditions
If code > 104 And code < 134 Or code = 101 Or code = 102 Then
Function residual(sign As Integer, code As Byte, price As Double, rs as
DAO.recordset) As Double
rs.FindFirst "[recid]=" & Forms!customermove!RecID
Do Until rs.BOF
residual = residual + rs("price") * rs("sign")
rs.MovePrevious
Loop
End Function
 
M

Marshall Barton

Kon said:
How can I use the bellow code using conditions
If code > 104 And code < 134 Or code = 101 Or code = 102 Then
Function residual(sign As Integer, code As Byte, price As Double, rs as
DAO.recordset) As Double
rs.FindFirst "[recid]=" & Forms!customermove!RecID
Do Until rs.BOF
residual = residual + rs("price") * rs("sign")
rs.MovePrevious
Loop
End Function


I've seen several versions of this question and I still
don't understand what you're trying to do. Somehow I've got
a feeling(?) that you can do this with a query, but I can't
be sure without a clear description of what you are trying
to accomplish.

I take a stab at this version of the question and guess that
maybe the code would look like:

Function residual(sign As Integer, code As Byte, _
price As Double, rs As DAO.recordset) As Double
rs.FindFirst "[recid]=" & Forms!customermove!RecID
Do Until rs.BOF
If (code > 104 And code < 134) _
Or code = 101 Or code = 102 Then
residual = residual + rs("price") * rs("sign")
End If
rs.MovePrevious
Loop
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top