Calculating in a form

SteveF

Registered User.
Local time
Today, 01:40
Joined
Jul 13, 2008
Messages
218
Hi all, it's dumb question time again :)

I'm trying to get a field in one of my forms to calculate a total and write the total to the relevant table.

I would like it to work like an excel spreadsheet, number '+' number then 'enter' gives a total. We enter till sales data and there may be several lines that need adding up, it can be tedious and slow on a calculator so I want to speed the process up by having Access do the adding up for me.

How can I get a field in a form to add up for me?

Thanks in advance for help.
 
You can have Unbound Textbox controls on your Form that either Sum or Add/Subract data in other controls on the same form or Main/Sub Forms.

You can also have controls that get their data by way of "influemce" from another control on your form or Main/Sub form - easliey done by Function.

If your Form is say, a Daily Balance Form and you want the cashier to enter data from the Days Takings and the form to calculate some final result and save same in a table, then you could use One or Al of the above.
Maybe then have a Command Button which is Clicked when you are satisfied with the result and the data is saved on a table.

Be mindful of saving data that can easily be provided by a query at any time.

To Sum Controls on a Form you use
Code:
=Sum([FieldName])
I use FieldName because you refer to the Form Datasource, not the form control name.
This is suited to a form Header or Footer where you have the sume continuous form detail recods.

To Add/Subtract you use
Code:
[control1name]+([contol2name]-control3name])
Here you use the form control name. This is suited to a single form or work in the form header or footer.
 
Thanks for response Bill.

I think what I'm after is a field that will accept data input like a calculator, so keying 1 + 1 'enter' will enter the total of 2 into the field. It will be entered into a table and then used in a query from there.

I have a calculator in a form already, what I'm trying to do is to get the form field to behave like the calculator or to have the calculator do its thing and then update the field.
 
You want to be able to type into One Control only "1+1" ?
There may well be a solution Out There to do this but for now, apart from wondering why you need to do this (instead of having two controls) then I imagine you could treat the entry as Text (string) and have string functions evaluate the entry.
eg read chrs before "+" and after "+". Convert the chrs to integers. Do the calcultions and save the result.
Sounds easy enough but two controls will allow you to do the same much easier.
 
Thanks guys. That might be enough for me to get this working, I will have another go at it today and let you know.
 
Two controls was the way to go, bound and unbound. The function works fine by the look of it so I just need to test it thoroughly and tidy up.

Thanks for help fellas.
 

Users who are viewing this thread

Back
Top Bottom