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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Form Field from Subform Field

Status
Not open for further replies.

rickyzicky

Programmer
Dec 20, 2001
35
US
What is the easiest way to update a bound field on a form from a calculated field on a subform?


RZ


 
In the 'after update' property of your subform field, you could fire a macro using the 'Set Value' function.

In the 'Item' line enter where you want the value to go.
[Forms]![FormName]![SubFormName].[Form]![SubFormFieldName]

In the 'Expression' enter what value to use.
[Forms]![FormName]![FormFieldName]

Note:
Calulated fields won't directly work.
You must enter the calculation in the 'Expression' line.
[Field1]*[Field2]

Hope that helps!
Tom
 
Thanks for the help. This actually works with one problem.
Here is the code in the Macro.

Item
[Forms]![supplies]![invbalance] - This is the field I am filling
---------------------------
Expression
[Forms]![supplies]![qtyf].[Form]![Expr1] - Where Expr is the value I am passing from the subform to the main form.
------------------------------
Once the macro is triggered in the AfterUpdate the value passes and the form freeze not allowing me to advance records or even go into design mode until it gives me an "error encountered" message and closes.

Any thoughts?

Expr1 is the calculated from 2 fields in a query.


RZ
 
Ok. I used the macro OnExit in a field and it works fine.
The only trouble is when there is a subform with no records the form is blank and there for I get an error since the field is not displayed.

How can I work around this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top