February 12th, 2013, 04:15 PM
Calculate Value Using Previous Record's Calculated Form Data
I'm looking for some help with referring to a previous record in a form and performing calculations with that value.
In my form, a user can adjust the "Percent" cell percentage to what they like. The neighboring fields, "Contributions" and "Interest" automatically recalculate new values based on the user input for the "Percent" field.
The "Fund Balance" value is the SUM of the previous record's "Fund Balance" (aka a running sum), along with addition of the previous "Contributions" and the previous "Interest" fields.
How can I get the "Fund Balance" field to automatically recalculate using data from the previous record's form calculation???
I am a noob so any help is appreciated, thanks.
February 12th, 2013, 07:52 PM
Is this a sum of all of the previous records, or only those viewed in this session by the user?
February 13th, 2013, 11:42 AM
Thanks for the reply!
Only those viewed in the session by the user.
This is because, of the presented records, the user could change the "Percent Value", which will automatically adjust the "Interest", and thereby needing the "Fund Balance" to be recalculated.
February 13th, 2013, 01:05 PM
Create an unbound text box on your form. Set the visible property to false. Set the default value to zero. This text box will store the information from the previous record that you want to recall. When you complete one record and move onto the next you simply add your desired value to the value already saved in the text box. Example
First record: Saved Value = 0 Value used for running sum = 150
when you go to the next record, use code to add the running sum value to the saved value
Second record: Saved Value = 150 Value used for running sum = 75
Third record: Saved Value = 225
and so on....
Since this is only a temporary value for while the user is logged in during this session, you could also use a global variable to save the value as well.
February 13th, 2013, 01:48 PM
I think I see the solution coming together, could you elaborate on the global variable a bit?
February 15th, 2013, 07:07 AM
I actually don't use global variable much. You'd be better off just doing a quick google search, a ton on info will come up.