Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to show the difference in an extra column 1

Status
Not open for further replies.

WingandaPrayer

Technical User
May 15, 2001
152
If I have two fields with one showing totals ,is it possible to show the difference in another column(Field3).

Example

Field1........Field2........Field3

name..........200..................
name..........157............-47
name..........104............-43
name...........68.............-36

Field3 is the one I would like.

Thanks in advance

David
 
See the following.

Pay CLOSE attention to the comments at the 'top'. Either your subtractions are WRONG, or I do not understand the problem statement.

Code:
Public Function basLastPassDelta(valIn As Variant) As Variant

    'Sample Given
    'name..........200..................
    'name..........157............-47
    'name..........104............-43
    'name...........68.............-36

    'As Calculated
    'name..........200..................
    'name..........157............43
    'name..........104............53
    'name...........68.............36

    Static LastPassVal As Variant      'Save previous value

    If (IsNumeric(LastPassVal)) Then
        If (IsNumeric(valIn)) Then
            basLastPassDelta = LastPassVal - valIn
        End If
    End If

    LastPassVal = valIn


End Function
MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Thank you Michael

Sorry about the explanation and "my" even worse calculation(example).
Even thru' all of that you still understood.

An extra question(s) please

How do I stop the calculation appearing on the first line and

can I show the calculations with a - sign if required

Example(with correct calculations!!!)

name..........200.............'no total required in this top row(stay blank)
name..........157.............-43
name..........104.............-53
name...........68..............-36

Thanks again,

David

 
AFAIK the "first" return will be a "Nothing" or blank so it SHOULD NOT 'show up' at all. I would 'suspect' that you have the field as a numeric type, and this is causing the 'non-value' return from the routine to be CONVETED to a zero.


The value returned is the diff between the previous value and the current value (200 - 147) which is (in this instance) a POSITIVE value. If you want to reverse this, just change the cal to be CurrVal - PrevVal.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top