update a bound control from subform

rdw456

Novice
Local time
Today, 10:40
Joined
Jul 20, 2012
Messages
43
Hello I have a Main form with several sub forms on it the tables behind each form are related tables. The user enters data on the main form with the exception of one bound control then moves on to enter data on the sub forms On exiting the record or the main form I want to take data from several of the sub forms and add them together and enter result in the bound form on the main form. Because this bound control is not used to enter data in there are no event triggers to code to get this done any ideas / solutions would be great.

Thanks in advance

Bob
 
IMHO the control on the main form should have its Control Source property set to an expression that does the required calculation. Normally, such calculations should be done wherever and whenever they are required with an expression. They should not normally be saved to a table.
 
Bob's right, databases don't usually store calculated numbers, you calc them when and where you need them. In your case, if the main form and sub form are in two seperate tables with the related records linked together, you can just run a sum query on the sub table.
However, if you still want to do it, set the control source to add up the values from the sub form as Bob suggested. This text box is unbound, meaning it just displays a number and is not linked to the table. Then on exit, assign this value to a another text box bound to the table. The second one is usually hidden, ie visible = No This will store the total for you.
 
Bob's right, databases don't usually store calculated numbers, you calc them when and where you need them. In your case, if the main form and sub form are in two seperate tables with the related records linked together, you can just run a sum query on the sub table.
However, if you still want to do it, set the control source to add up the values from the sub form as Bob suggested. This text box is unbound, meaning it just displays a number and is not linked to the table. Then on exit, assign this value to a another text box bound to the table. The second one is usually hidden, ie visible = No This will store the total for you.
This will save the total to a table, but, it seldom appropriate to do so. When it is not appropriate, it ends in tears. If rdw456 can tell us more about the data, perhaps we could give more advice.
 

Users who are viewing this thread

Back
Top Bottom