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

calculating sum from datasheet in subform

Status
Not open for further replies.

caman74

IS-IT--Management
Jan 1, 2005
67
NO
Hello.

I have a subform [frmMeasurements] inside a form [TrspOppdrag].

The subform has the following txtboxes:
*[txtMeaID] - Autonumber
*[txtCopyTrspID] - looks up value from a textbox in main the form called [txtTrspID]
*[txtnumber] - manually input
*[txtlenght] - manually input
*[txtwidth] - manually input
*[txtHeight] - manually input
*[txtWeight] - manually input
*[txtM3] - gets its value from [txtSumM3]
*[txtLM] - gets its value from [txtxSumLM]
*[txtSumM3] - uses NZ to calculate cbm from the above values.
*[txtSumLM] - uses NZ to calculate loading metres from the above values

Several lines may be added to the subform, but it is related to the autonumber [txtTrspID] in my main form, so the values "follows each post".

Both the subform and the main form has its own tables.

This is a fairly easy form/subform assemblage.

Here is my problem:
What I need to happend is; when [txtTrspID] in the main form gets in "focus", all the values under [txtM3] needs to be added and shown in a txtbox in my main form called [txtVolum].

I'm now using the following on focus control "Forms![TrspOppdrag].[txtVolum] = Me.txtSumM3" and this partly does what I want.
The only issue here is that it only shows the first [txtM3] value, and will not add the rest of the [txtM3] values when they exists.

Hopefully this made any sense...

Chris
 
I found a solution.

I just placed "=Sum([txtM3])" in an unbound txtbox in the footer of the subform, and all the calculations I needed were done there.

Then it is just to link that value to wherever I need it.

Thanx anyway!

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top