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

How do I create subtotals on a form that relate to values selected on a list?

P: 2
I have an unbound listbox (list1) on my form.
Another unbound listbox (list2) that shows the totals of the values in the months in (list1)
I am trying to add a third listbox (list3) that subtotals the selected items in (list1)

I have multi-select set to extended to allow the multiselection.

I suspect I need to code something with the listindex and itemsselected?

Was hoping to copy (list2) query and add a filter using listindex, but can't get my head around that.

Would put my code on here, but there is an awful lot more going on in this form, and it would probably complicate things...and my coding is untidy !!! lol
Jan 27 '10 #1
Share this Question
Share on Google+
3 Replies

Expert 2.5K+
P: 3,072
I would simplify things by adding a YesNo field to the table. This enables the user to select rows without the CTRL pressed and thus "more stable" (a simple click can undo such a multiselect :-( ).

Having the YesNo field will easily allow you to total the rows by adding the YesNo field to be True.

You could even add a (de-)select all button that performs an UPDATE of the YesNo field for all rows in the table.

When you check my Left/Right listbox sample ( you can see how I use such a field to determine in what listbox a row has to appear and by the > and >> buttons how the UPDATE is handled.

Getting the idea ?

Jan 28 '10 #2

P: 2
Hi Nico,
Thanks for the response. I get the idea, and have downloaded and looked at your code (which I may use elsewhere!) but I'm not sure as I can get this to practically work for my requirements. What I am after is similar to Excel where you have the "quick sum" ability in the bottom right hand corner in the status bar. You can easily and quickly hold down control/Shift and select multiple non-adjacent cells and see the sum instantly, but affect nothing structurally. (Stability is not an issue, as it is only meant to be a quick and dirty calc. to save time.) This access application I am building will be used in an active meeting, and will be fast paced, so speed is required even if I have to work on some more complicated code. Any other angle or a way you can think of?

Thanks for your thoughts so far.
Jan 29 '10 #3

Expert 2.5K+
P: 3,072
The YesNo field approach can be used for a quick sum by using an unbound field with a DSUM like:
Expand|Select|Wrap|Line Numbers
  1. =DSUM("MyNumericValue","MyTable","YesNo=True")
The other solution would be to loop in code through the SelectedItems of the listbox and sum them in code.

Jan 30 '10 #4

Post your reply

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