Full Version: Automatic calculation
UtterAccess Forums > Microsoft® Access > Access Forms
YZF
Hi there,
anted to ask if it is possible in access form to have automatic calculation of certain fields in real time. Now when you type something in one field (numbers) you have to press with mouse somewhere else to "accept" that input and access shows calculation in other field.But is it possible to make so that after you fill first number in field, it would immediately calculate result in another field, then you can fill one more number and it would calculate "new" value in another field and so on....
In other words, results would show up as you type.
Thanks!
RuralGuy
Look into the AfterUpdate event or maybe even the Change event of your controls. AfterUpdate event occurs when you move to another control and the Change event occurs at *every* keystroke while in the control.
YZF
Yes i noticed that...but what about situation when I want calculation from different record...e.g. from view "continuous" (many records in one page) and at the bottom one field that sums everything using SQL (I think?) function: =Sum()
This way i don't use afterupdate/on event at all....i think....right? when i make my calculation formula...
Thanks!
RuralGuy
Present a specific problem and we'll attempt to provide a specific solution.
YZF
I atach example.

I want to type numbers in "price" field and see the results in "Total" field immediatelly after i type number (without clicking mouse on different field to make it calculate result).
RuralGuy
Try this one!
YZF
You made a small mistake: TotalPrice field name should have been changed to CalcTotal, because it didn't work at first.
But now its ok, it works and that was what i wanted frown.gif
Thank you!
YZF
One more question:
Ocan fill in only single numbers in "price" field, but how to make it accept General Numbers? E.g. 10,5 12,123 (not only 10 or 12 ) ?
Tried to change field properties but it didn't work...
Thanks
RuralGuy
You will need to change the field type from Long Integer to Currency or floating point such as Single or Double.
YZF
I did change it but it won't work.....it shows me "wrong value error" and gets me to vba code part "me.dirty"....

Any ideas how to fix it?

Thanks!
RuralGuy
This is as close as I can get it. Making everything instantaneous causes problems. I'm not satisfied with the feel but maybe someobe else will have some suggestions.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.