Hi Buddy!
This is quit simple. You allready have all data needed to make the
calculation stored so you dont need to store the result since you can
calculate it everytime you need it.
I guess that you have a combobox control in your form which you look up the
tube size? If not this might be a good idea and naming the combobox
something like cboTubeSize. If you use the wizard when creating the combobox
make sure you selecte the third option if so it will automaticly look up the
correct value for the weight (in control txtWeight on the form).
To be abel to do this you need to have a primary key (a unique key) in your
tabel with the tube size and weight. So each size get´s it´s own unique
value which access can look up and get value for in field with the weight
and size.
Then create 5 unbound textcontrols on your form:
txtTopRailLength
txtBottomLengtRail
txtWeightOfTopRail
txtWeightOfBottomRail
txtTotalWeight
Set controlsource for each of them to following (only the text after the =
sign):
txtTopRailLength = (this one should not have any controlsource)
txtBottomLengtRail = (this one should not have any
controlsource)
txtWeightOfTopRail = ([txtTopRailLength]*[txtTubeWeight])
txtWeightOfBottomRail = ([txtBottomLengtRail]*[txtTubeWeight])
txtTotalWeight = [txtWeightOfTopRail]+[txtWeightOfBottomRail]
That´s it!
If you need to do this calculatione somewhere else, in reports for instance)
you do exactly the same. And as you will learn many things in Access can be
done in several ways, this was just one of them.
As you can see I use names on my controls so it´s easyer to know what
control or fields I´m refering to. So I suggest that you rename the fields
in your tabel to something meaningful instead of field1, field2. As long as
you only have a few fields and only one tabel you might remember which
fields is what kind of data. But if your db grows...
I hope this helps you out!?
// Niklas
So, cretae a control