Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Results of unbound into bound control. 3

Status
Not open for further replies.

storyboy

Programmer
Sep 16, 2004
25
US
Where is the best place to put calculations. Here is the problem. Within the bound control on my form, I have been putting calculations in the Control Source Property. This calculation is based on entry of other fields, shipping cost, and discount amount, etc. I need to see the result of the calculation in the form, but then it doesn't get saved in the table bound to the form. I am new to this, and this seems so simple but I am missing something. After hours of trying perhaps I have tunnel vision and can't see my error. Thank you for any and all help you can be. With out you I would be sunk. Thanks again. I know that this is outside good database design, and I have been told such practice in not encouraged, but, I must find a way to do it. The calculated result must be stored in table as so many other things in the system require it being there, not recalculated. Please HELP. and Thank you. I did try an creat bound box and then (one equals the other), does not work. Thanks Tom
 

Okay so we dispence with the "You are doing a very bad thing" story - You already know you are walking with the faul beasts of the underworld and your Access Developer Soul will spend seven years in pergatory for the act you are intending to commit .. .. ..


So you want ME to help you ?
What does that do to me soul ?


Anyway.
There must be some sort of thing happening that causes the values that go into this calculation to change.

Eg. ( A simple version )
If you have a form with four text boxes on it

txtA
txtB
txtC
Result

Result.ControlSource = ( txtA * txtB ) / txtC

Yet YOU want to Bind Result to a field in the bound table to store the result !

SO In the txtA.AfterUpdate event put the following code
Call UpdateResult()

Put the same codse in the afterUpdate event of txtB AND txtC

Then delete the Result.ControlSourse and bind it to the field in the table where you want to store the data.

Then add code

Private Sub UpdateResult
If Not (IsNull(txtA) OR IsNull(txtB) Or IsNull(txtC)) Then
Result = ( txtA * txtB ) / txtC
End If
End Sub


That will do the trick you need.



'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
PS.

The "Private Sub UpdateResult" code goes on the code page for the Form itself, ( The Form's Class Module ) along with the txtA_AfterUpdate event etc.


'ope-that-'elps.

G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
All worked great, I am very excited that I can now stuff that data into the table. There are 27 activities that depend on that data being there, and not constantly recalculated. There are rules, then there are exceptions. I thank you so much for your help and assistance. Appears you are very wize.
Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top