By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,414 Members | 2,919 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,414 IT Pros & Developers. It's quick & easy.

Getting Sum in Subform (dual combo box driven)

P: 1
Source: this is an access 2003 question
My knowledge level: reading books, internet, and trial & error; no formal training

I'm trying to get a running sum of what's filtered in a subform which is ultimately driven by the results of two combo boxes: 1st combo box on main form that filters desired results for 2d combo box on sub form

Main form: no record source. Has an unbound combo box.
name: frminput
combo name: cboAccounts
The row source for the cboAccounts is a list of accounts from an account table.
---SELECT DISTINCT tblAccount.AcctName FROM tblAccount ORDER BY tblAccount.AcctName;
The AfterUpdate for this combo box has 2 lines:
---Me.Form!subInput.SetFocus
---Me.Form!subInput!cbogroups.Requery

sub-form name = subinput
its control source is from a table that has the fields the user has to input
2d combo box = cbogroups (results driven by what user selects in above combo described for main form)
The combo box row source is from a query which houses the parameter for making my cascade work. This particular query feeds from a table I set up just for the different groups.

My cascade combo box set up works fine in as far as the 2d comb box retrieving results directly associated with the account the user selects.

Here's my problem: the user has to input costs associated with these accounts. But I need a running sum to appear at the bottom of the main form so he can see how much he is spending in the account. Nothing I try works. Various places I've read seem to suggest (in my limited programming understanding that is) that my problem is that the subform is feeding from a table rather than a query, that if I had a query then I could set up calculations to achieve sum results. Is this true???

On the assumption the query was the answer, I did try setting up a subform that feeds off a query rather than a table but then I couldn't get my 2d combo box to work at all.

my subform (which is set to datasheet) looks like this:
group (cbogroups combo box), Jan07, Feb07, Mar 07 (etc for all months) (there are many other fields but for brevity sake I'm only showing a few)

So the user selects an account from the main form, this filters relative groups to the second combo box in the subform, and then from those available groups he selects each one and then inputs costs associated with that group.

EXAMPLE:
Let's say he selected Account: Electrical and that it has groups L1, L2 and L3 associated with that account. For L1 he has $10 for Jan, $20 for Feb; for L2 he has $20 for Jan, $25 for Feb. For L3 he has $100 for Jan $110 for Feb and $300 for Mar. So for Electrical for the year he has spent $585. Down at the bottom of the main form he needs to see the $585 total. It should be an active field that updates as he makes changes in the subform.

The closest I've come to getting this to work was achieving a total for each group (in other words it'd give me L1 total, then when I changed records to the next group it'd give me L2, etc) but I can't get the total for ALL of the groups by an account to appear.

Can anyone help me?
Apr 29 '07 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
Put a textbox in the subforms footer to total the required field.
Now put a field on the main form and set it to the value in the aforementioned textbox using the following formula.

Expand|Select|Wrap|Line Numbers
  1. =Forms![Main Form Name]![Subform Name].Form![Subform Textbox Name]
Apr 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.