locked
adding ten fields (different fees) to a display field on a form RRS feed

  • Question

  • I have ten different fees on a form for which I want to show a running total in a text field that is not part of the table that the ten fields come from.

    I have tried several tactics 

    1. the running total field contains "=CurrRunningSum()" a function that adds each field 

    2. the running total is updated by a Sub that adds each field and is prompted by the exit event of each of the ten fields on the form.

    Either of these is invoked in the Form_Current event as well.

    Each approach has deficiencies.

    The first seems to work only on saved records and not on new ones which suggests that I am not referencing the fields appropriately on a new record.  I have tried several ways of referencing the fields including

    me.[fieldname],

    me.controls("fieldname")

    me.fieldname (no brackets, with underscores for spaces.)

    I have also protected against null entries and datatype differences with a function called "Makeval" that converts each field to a number.

    This seems like it should be easier than it has turned out to be.

    Any good references on doing something like this will be appreciated.

    Marj Weir

    Friday, February 12, 2016 5:43 PM

Answers

  • I successfully got around whatever was fighting me.  Instead of using the field names, i gave each of them a tag called "Fees."  Then I referenced them  in a subroutine using a "For Each ctrl in Me.Controls" loop that operated only when the control had that tag.  I invoked the subroutine at the Form)Current Event and at the Exit event of each of the fee fields.  This finally worked for both existing records and new records.

    Marj Weir

    • Marked as answer by Marj Weir Saturday, February 13, 2016 6:57 AM
    Saturday, February 13, 2016 6:57 AM