jmasterx
jmasterx

Reputation: 54113

Compute subform total

I have a sub form that looks like a datasheet view. It returns prices from a query I made. Essentially I want to compute the total of those prices using vba. I just do not know how to get all the prices and put them into an array.

Here is a picture to get a better idea: enter image description here

I want Compute Total to compute the total.

The record source for the sub form is:

SELECT [Rental Query].[CopyNo], [Rental Query].[RentalNo], [Rental Query].[Title], [Rental Query].[Format], [Rental Query].[DaysRented], [Rental Query].[Price] FROM [Rental Query];

I'm interested in the Price. The query uses a specific formula to create that field.

What I want is to be able to get all the prices and sum them.

Thanks

Upvotes: 1

Views: 104

Answers (1)

Fionnuala
Fionnuala

Reputation: 91326

You can add a textbox to the form footer and set it to:

=Sum(MyField)

You will not be able to see the control in datasheet view, but you can refer to it on the main form in a textbox:

=MySubformControl.Form.MySumControl

Upvotes: 1

Related Questions