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

Form SubForm question 1

Status
Not open for further replies.

puforee

Technical User
Oct 6, 2006
741
US
I have a Form (Location) Sub-form (Customer) Sub Sub Form (Items Purchased)

On Items Purchased I have fieds of Quanity and Price...I also have a computed field =[Quanity]*[Price] named Total.

On the Customer sub form I want a text box (CustTotals) to compute the sum of all the "Total" fields on the Items Purchased form.

I used this in the CustTotals field of the Customers form

=Sum([Sales SubForm].[Form]![Total]) and I get #Error

I know I have done something like this before...what am I doing wrong
 
Thanks Bob,

Also, can you answer one question about the code we used....
=DSum("Total","Sales Tbl Query","Location = " & [LocationID])

What does the last part " & [LocationID]) do. Can you explain this criteria please?
 
What does the last part " & [LocationID]) do. Can you explain this criteria please?
The criteria is that we are trying to match the Location in the query with the [LocationID] which should be a control on your form which has LocationID bound to it. In this context you don't need to reference the form or anything like that if the control is on the same form where this control source is located. So we just use the control name in square brackets.

I hope that helps.

Bob Larson
Free Access Tutorials and Samples:
 
OK...I understand the Location comes from the Sales Tbl Query.

And I understand the LocationID is on the Location Form where the Unbound Text field containing =DSum("Total","Sales Tbl Query","Location = " & [LocationID]) is located.

But why the ampersand & befor the [LocationID]

Thanks,
John
 
But why the ampersand & befor the [LocationID]
Because we want the VALUE of [LocationID] not the word [LocationID]. So instead of trying to evaluate the expression we are, by concatenating the reference in, giving the function the actual VALUE that [LocationID] represents.


Bob Larson
Free Access Tutorials and Samples:
 
Thanks...I will keep this in mind for future projects....that was the last question. Have a wonderfule day.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top