Full Version: Field To Show Total Score
UtterAccess Forums > Microsoft® Access > Access Forms
Hi everyone,
I have a txt field on my form that I want to use to show the total of the scores selected for 5 items on a score sheet which range from 1 - 5 via a cbo...
I have tried setting the record source of the text box to various things and am not getting what I need.. I either get a concatenation of each score selected or an #Error in the field...
Any ideas as to what I am missing??
Jeff B.
Without an idea of what you've already tried, we may just be re-inventing what you've found doesn't work.
enerically, you could put something like the following in the ControlSource property of that textbox:
=YourFirstControl + YourSecondControl + ...
Now, if any of those controls could contain a null, you need to modify it like:
= Nz(YourFirstControl,0) + Nz(YourSecondControl,0) + ...
Then, if any of your controls are comboboxes, are you trying to add the key value, or the displayed value?
Then, after each of the controls are updated, you'll need to have the form re-paint to show the (new) resulting calculation...
Good luck!
Sorry about that. I've tried
= conrtol1 + control2... and it just places each value one after the other (ex: 45 when the first control has a 4 selected and the second has a 5). I've tried Sum(contrl1 + contrl5) and it gives #Error.
The data of my cbo's are set via value list and a source of:<< "1";"Poor/Breach";"2";"Major Improvement";"3";"Some Improvement";"4";"Minor Improvement";"5";"Excellent" >>
When the user selects one, the number is what shows in the cbo box and that is what I want to add and be displayed in the "total score" field as the user scores each element...
Your ComBox returns String value so the plus (+) operator is interpreted as concatenation operator.
You need to wrap the refs in Val() like:
= Val([Control1]) + Val([Control2]) + ...
Ok well that's wierd... on my laptop i tried your suggestion and it works, the wierd part is when i use the previous ( = control1 + control2 ) record source it works as well...
Are there any settings from one systems access program that would cause the difference in behaviour? I haven't tried your solution on the other PC yet because im not at work today... will try it monday..
>>Are there any settings from one systems access program that would cause the difference in behaviour?<<
Not AFAIK of... You might have used a different Value List, perhaps?
FOr the ComboBoxes on the other set-up are bound to numeric Fields? In this case, it is more than likely that Access performs automatic type-casting for you.
Ahh that might be it. I changed it on the work pc, I had initially set it to pull the cbo row source from a table via an sql query and found that the slight delay in showing the values wasn't worth it so I set it to a value list on the work pc so it's not bound...
'll check that Monday then.
You're welcome... Glad we could help...
yesss that worked.
Glad to hear that it worked...
Cheers " emoid=":thumbup:" border="0" alt="thumbup.gi
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.