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

Calculating totals from a subform

Status
Not open for further replies.

Knackers

Technical User
Apr 26, 2001
59
AU
Hi,
I have a subform that calculates the number of working days between two date (using a module and a table of holidays) and then an expression that calls the module (deltadays=([holidaystart],[holidayend])).

I want to return the calculated total (Sum?) of these days to a control in the parent form. Can anyone tell me how I might do this?

Thanks!
 
You can easily link a field on a parent form to a field on a subform, I suggest using the expression builder for this though, just to be on the safe side. If that does'nt work you could duplicate the SQL query on your subform into a query, then total it from there, and display it as a combo box (remembering to requery it whenever you change start/end dates etc).

Andrew.
 
Thanks Andrew.
I think that I may have been a little unclear on what I was trying to acheive. The value that I want to display in the parent form is the sum of the working days in the subform.

The help files say that when computing a total with an aggregate function such as Sum in a form that you can't use the name of a calculated control in the Sum function. You must repeat the expression in the calculated control.

I have tried this using = Sum(=deltadays([holidaystart],[holidayend])as the calculated control but it doesn't seem to work.
 
I would define a non-visible text box (txtSumDeltaDays) in the footer of the subform that had as its control source: =sum([DeltaDays])

Then, in the form I would have a text box with something like the following as its control source: =[frmMain subform].[Form]![txtSumDeltaDays]
 
I was wondering what Kramer was doing these days - Access guru?

Thanks for your advice. I have got the sum([Deltadays]) to work in the footer of the subform without any problems. However, when I try to use it as a control on the main form, al I get in the text box is #Name?

( I used the expression builder to select the txtSumDeltaDays)

Any ideas?
 
Where I put "frmMain", that should be the name of your subform....You might want to check that...

We are all the masters of our own domains...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top