Using a value calculated in a subform to populate a field in a tab

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with a linked subform that performs a calcluation. After the
calculation is performed in the sub form I would like the value to be added
to a field in a related table. I have tried various after update event
procedures trying to call the value of the sub form, but nothing seems to be
working. Any suggestions??

Thanks
 
Not knowing what you've tried nor which "AfterUpdate" event you're using
(the form's? a control's?), here is how you generically get the value of a
control in a subform when you are on the main form:

Me!NameOfControlOnMainForm.Value = _
Me.SubformName.Form.NameOfControlOnSubform.Value

or

Me!NameOfControlOnMainForm.Value = _
Me!SubformName!NameOfControlOnSubform.Value

where SubformName is the name of the subform control (the control that
actually holds the subform object).
 
Thanks. I can get the value from the subform onto the main form. What I want
to do is take the value calculated in the subform and have it added to the
underlying table. I've tried the following using the AfterUpdate for the
control:
Me!
.[field].Value = [Forms]![MainForm]![subform]![field].Value
Me!
.[Field].Value = Me! [Forms]![subform].[field].Value

I'm sure my code is totally messed up, but I know I've done this before. I
just can't seem to remember how... very frusturating.
Thanks
 
MT_dma said:
I have a form with a linked subform that performs a calcluation. After
the calculation is performed in the sub form I would like the value
to be added to a field in a related table. I have tried various after
update event procedures trying to call the value of the sub form, but
nothing seems to be working. Any suggestions??

Thanks

Are you sure you really want to store the result of a calculation?
Normally Access is much happier just re-computing each time it needs the
results than storing them. It also eliminates the problem of making sure
everything get's updated if a source number is changed.
 
If a control is bound to the desired field, do this:

Me!ControlName.Value = [Forms]![MainForm]![subform]![field].Value


If there is no control bound to the field, and the field is in the form's
recordsource, do this:

Me.[field].Value = [Forms]![MainForm]![subform]![field].Value

--

Ken Snell
<MS ACCESS MVP>

MT_dma said:
Thanks. I can get the value from the subform onto the main form. What I
want
to do is take the value calculated in the subform and have it added to the
underlying table. I've tried the following using the AfterUpdate for the
control:
Me!
.[field].Value = [Forms]![MainForm]![subform]![field].Value
Me!
.[Field].Value = Me! [Forms]![subform].[field].Value

I'm sure my code is totally messed up, but I know I've done this before.
I
just can't seem to remember how... very frusturating.
Thanks



Ken Snell said:
Not knowing what you've tried nor which "AfterUpdate" event you're using
(the form's? a control's?), here is how you generically get the value of
a
control in a subform when you are on the main form:

Me!NameOfControlOnMainForm.Value = _
Me.SubformName.Form.NameOfControlOnSubform.Value

or

Me!NameOfControlOnMainForm.Value = _
Me!SubformName!NameOfControlOnSubform.Value

where SubformName is the name of the subform control (the control that
actually holds the subform object).
 
The first piece of code worked.
Thanks a bunch.

Ken Snell said:
If a control is bound to the desired field, do this:

Me!ControlName.Value = [Forms]![MainForm]![subform]![field].Value


If there is no control bound to the field, and the field is in the form's
recordsource, do this:

Me.[field].Value = [Forms]![MainForm]![subform]![field].Value

--

Ken Snell
<MS ACCESS MVP>

MT_dma said:
Thanks. I can get the value from the subform onto the main form. What I
want
to do is take the value calculated in the subform and have it added to the
underlying table. I've tried the following using the AfterUpdate for the
control:
Me!
.[field].Value = [Forms]![MainForm]![subform]![field].Value
Me!
.[Field].Value = Me! [Forms]![subform].[field].Value

I'm sure my code is totally messed up, but I know I've done this before.
I
just can't seem to remember how... very frusturating.
Thanks



Ken Snell said:
Not knowing what you've tried nor which "AfterUpdate" event you're using
(the form's? a control's?), here is how you generically get the value of
a
control in a subform when you are on the main form:

Me!NameOfControlOnMainForm.Value = _
Me.SubformName.Form.NameOfControlOnSubform.Value

or

Me!NameOfControlOnMainForm.Value = _
Me!SubformName!NameOfControlOnSubform.Value

where SubformName is the name of the subform control (the control that
actually holds the subform object).

--

Ken Snell
<MS ACCESS MVP>


I have a form with a linked subform that performs a calcluation. After
the
calculation is performed in the sub form I would like the value to be
added
to a field in a related table. I have tried various after update event
procedures trying to call the value of the sub form, but nothing seems
to
be
working. Any suggestions??

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top