How to update a main form from a calculated field in a subform (1 Viewer)

fabio

New member
Local time
Today, 10:31
Joined
Oct 14, 2010
Messages
8
I have a subform embedded in a main form, the subform has a field (text box) that is doing automatic calculation so no manual entries are needed from the user. I have tried to pass automatically the final result to a text box in the main form, but all events are not working (afterupdate, On change, On Dirty), etc.

I have a button to do the above mentioned in the main form, but I don’t want to use that button, I want to do all the process from the subform.

Also, from the subform I was able to do click on the button on the main form (programmatically), however MS Access is too quick and the value extracted from the subform is always empty (zero); Acees is finishing before the calculation is done.

I did search in the internet, and I expend too many minutes trying to find a solution but until know I have not been found any success.

I am using MS Access 2010.

Any help will be highly appreciated.

Thank you,

Fabio
 
Last edited:

Poppa Smurf

Registered User.
Local time
Tomorrow, 02:31
Joined
Mar 21, 2008
Messages
448
To display the final result on the main form use the following syntax

Field name= [Name of Subform].[Form]![name of control on subform]

Example - Suppose your want to display the current Balance of your deposits and withdrawals from your subform in the Account Balance on your form.

1. Balance is a hidden control on your subform that is the total of your deposits and withdrawals.
2. Account Balance is the field displayed on your main form
3. The Control Source property for Account Balance is set to =[Accounts Subform].[Form]![Balance]
4. A change in your subform will update your field on the main form.
 

fabio

New member
Local time
Today, 10:31
Joined
Oct 14, 2010
Messages
8
Thank you Poppa Smurf for your answer, the proposed solution works.

However please let me know how can be passed the value of this calculated field to another text box (the control source of this text box is a query field). It is my final purpose. and I want to do this programatically (VBA), so no user interface expected.

I have tried again events such as Afterupdate, Ondirty, etc. but they don;t work at all.
 
Last edited:

missinglinq

AWF VIP
Local time
Today, 11:31
Joined
Jun 20, 2003
Messages
6,423
...let me know how can be passed the value of this calculated field to another text box (the control source of this text box is a query field)...
Short answer is...you don't! This is a calculated Field and while there are a few highly specialized situations where it is appropriate to store calculated values, this type of thing is not one of them. You simply re-calculate the value, as needed, for other Forms, Reports, etc.

Linq ;0)>
 

fabio

New member
Local time
Today, 10:31
Joined
Oct 14, 2010
Messages
8
Short answer is...you don't! This is a calculated Field and while there are a few highly specialized situations where it is appropriate to store calculated values, this type of thing is not one of them. You simply re-calculate the value, as needed, for other Forms, Reports, etc.

Linq ;0)>


Missingling:

Thank you for your answer. As indicated I need to pass the value of this calculated field to another text box (the control source of this text box is a query field) in the same form programatically, any suggestion will be highly appreciated.

Thank you again,

Fabio
 

Users who are viewing this thread

Top Bottom