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

Subforms

Status
Not open for further replies.

kpryan

Technical User
Aug 24, 2005
282
0
0
US
Hi all,

Could I have some help please on this one.
I have a form which includes a subform. On the subform I have some currency fields which have currency data.
On the main form I want to add this data on the subform to fields on the mainform to give a combined total.

Many thanks,

ken
 
Me.Parent.[Control name] or Me.Parent.ControlName = Me.[subform control name] or me.SubformControlName
 
Do you want to put say the sum of the currency field from the subform on to a field on the Main Form (e.g. from a Datasheet/Continous Subform) to be used in a calculation for a combined total on the Main Form?


 
Many thanks for your replies, but could you help me further.
On the subform I have a field Q1Gross. On the mainform I have Q2Gross plus Q3Gross.
I want Q3gross to equal Q1Gross + Q2Gross.
How would I include the code as shown above.

Many thanks,

Ken
 
Thanks for the reply. I wanted it to be triggerd on the update of the main form.

Many thanks,

Ken
 
Then on the before update or after update event of your main form

Me.[Q3Gross] = val(Forms![subform name]![Q1Gross]) + val(me.[Q2Gross])

Keep in mind that the val are only present if you have string returned in those txtboxes and also that you can't return control for subforms in datasheetview.
 
hit submit too fast. If you have a delay between the sum is returned, try using Me.Recalc
 
Hi,
Many thanks for your reply. Do appreciate it.
I have tried using the code, but get an error 'cant find the Sunform which is named form2a.
How do you reference the subform to the main form.
Many thanks,

Ken
 
Are you using the subform name or the subform control name? You need to use the control name.
 
The reference needs to be the one has a Form control and not the name of ur main subform, go check in ur main subform and check subform porperties > name
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top