Form Subform DLookup

J

John

Team,

I have a Form / Subform (with tabs)

On the Subform, I want to:
1. Sum values located on the Form to values located on the Subform.
2. Be able to add a new record for a subsequent Change Order.

The latest attempt has been to display the sum is:
Private Sub txt_Change_Order_Current_Agreement_Value_AfterUpdate()
Me!txt_Change_Order_Current_Agreement_Value =
DLookup("ZPCM_Agreement_Value", "ZPCM", "ZPCM_ID=" & Me!txt_ZPCM_ID)
End Sub

It appears that the sum and the adding of a new record are mutually
exclusive. Is my assumption correct?
 
N

nrgins via AccessMonster.com

Your post is not clear. But, to get a value located on the subform from the
main form's code module, use this syntax:

Me.SubformcontrolName.Form!SubformValue

where SubformcontrolName is the name of the control on the main form that
holds the subform, and SubformValue is the field on the subform that you want
to look up.

If you want to sum values on a subform, simply put a (hidden or not hidden)
control in the subform's footer, and set its controlsource value to "=Sum(
[ControlName])" (without the quotes) where ControlName is the name of the
control you want to sum. You can then just refer to that summation control
from the main form using the above syntax.

HTH,

Neil
 
J

John

Neal,
thanks for your reply.

Let me clarify my thoughts...

My Form: ZPCM_form (has the value i want).
My subform: "Change_Order subform" (needs the calculation).

So, i need to:
1. pull the value in ZPCM_form (ZPCM_Agreement_Value) and
2. add it to Change_Order subform (Previous_Change_Order_Value) and
3. place the new resultant value in TextBox123.

Hope this is clearer.

--
Thanks for your time...

John


nrgins via AccessMonster.com said:
Your post is not clear. But, to get a value located on the subform from the
main form's code module, use this syntax:

Me.SubformcontrolName.Form!SubformValue

where SubformcontrolName is the name of the control on the main form that
holds the subform, and SubformValue is the field on the subform that you want
to look up.

If you want to sum values on a subform, simply put a (hidden or not hidden)
control in the subform's footer, and set its controlsource value to "=Sum(
[ControlName])" (without the quotes) where ControlName is the name of the
control you want to sum. You can then just refer to that summation control
from the main form using the above syntax.

HTH,

Neil

Team,

I have a Form / Subform (with tabs)

On the Subform, I want to:
1. Sum values located on the Form to values located on the Subform.
2. Be able to add a new record for a subsequent Change Order.

The latest attempt has been to display the sum is:
Private Sub txt_Change_Order_Current_Agreement_Value_AfterUpdate()
Me!txt_Change_Order_Current_Agreement_Value =
DLookup("ZPCM_Agreement_Value", "ZPCM", "ZPCM_ID=" & Me!txt_ZPCM_ID)
End Sub

It appears that the sum and the adding of a new record are mutually
exclusive. Is my assumption correct?
 
N

nrgins via AccessMonster.com

Clearer, but still not totally clear.

What triggers this calculation?

Where is TextBox123 -- on the main form or subform?

OK, let's assume that everything happens on the subform (since that's the
easier scenario :) ). That is, user does something on the subform (enters a
value, clicks a button, whatever) that triggers this calculation, and the
result is then written to TextBox123 on the subform.

In that case, it's simple: in the subform's code module, get the value from
the parent form (ZPCM_form) using the Me.Parent syntax, as follows

Me.Parent!ZPCM_Agreement_Value

If you're not doing everything in the subform, then you'll need to be clearer
in your explanation (and please be clearer in the future so as to avoid all
this back and forth - thanks!).

Neil

Neal,
thanks for your reply.

Let me clarify my thoughts...

My Form: ZPCM_form (has the value i want).
My subform: "Change_Order subform" (needs the calculation).

So, i need to:
1. pull the value in ZPCM_form (ZPCM_Agreement_Value) and
2. add it to Change_Order subform (Previous_Change_Order_Value) and
3. place the new resultant value in TextBox123.

Hope this is clearer.
Your post is not clear. But, to get a value located on the subform from the
main form's code module, use this syntax:
[quoted text clipped - 36 lines]
 

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

Top