473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

saving calculated values

I've got a temp table that contains the fields: amountowed, amountpaid, and
balanced. I've got a form that shows this information and I've set it up so
that when the amountpaid field is changed it subtracts the amountpaid from
the amountowed and display's it in the balanced field.

Unfortunately it doesn't save what is displayed back to the table. It does,
however, save the changes to the amount paid field. I'm assuming my problem
is that the balanced field in the form is showing an expression as it's
control source so it's technically unbound. But when I bind it to the right
field in the table I can't get it to update anymore.

Long explanation just to ask...
Anyone know of a way to update fields 'on the fly' and still have the
calculated value saved to the underlying table?

-jeremy

Nov 12 '05 #1
3 5311
"Jeremy Weiss" <jw*****@hotmail.com> wrote
Anyone know of a way to update fields
'on the fly' and still have the calculated
value saved to the underlying table?


If the calculated Control has the calculation expression in its Control
Source, then in the AfterUpdate event of each other Control that can be a
factor in the calculation, copy the content of the Calculated Control into a
Text Box control bound to the Field where you want it saved.

Alternatively, you could bind that Control to the Field that you want
updated, and perform the calculation in VBA code in the AfterUpdate event of
each other Control that can be a factor in the calculation.

Obligatory caution: if you are storing something that can be calculated from
other values when it is needed for display or use, then it is redundant
storage, and a violation of RDB design principles.

Larry Linson
Microsoft Access MVP
Nov 12 '05 #2
bo*****@localhost.not (Larry Linson) wrote in
<6x**************@nwrddc03.gnilink.net>:
"Jeremy Weiss" <jw*****@hotmail.com> wrote
Anyone know of a way to update fields
'on the fly' and still have the calculated
value saved to the underlying table?


If the calculated Control has the calculation expression in its
Control Source, then in the AfterUpdate event of each other
Control that can be a factor in the calculation, copy the content
of the Calculated Control into a Text Box control bound to the
Field where you want it saved.

Alternatively, you could bind that Control to the Field that you
want updated, and perform the calculation in VBA code in the
AfterUpdate event of each other Control that can be a factor in
the calculation.

Obligatory caution: if you are storing something that can be
calculated from other values when it is needed for display or use,
then it is redundant storage, and a violation of RDB design
principles.


Er, not in the case of an apply payments temporary table, which is
what he's working on.

I do this with a checkbox field. You click the checkbox and the
AfterUpdate of the checkbox sets the balance and payment fields.
Because of that, you need an original balance field so you can
revert to it if you uncheck the invoice.

Say you have this:

InvTotal OrigBalance PmtAmt NewBalance
100.00 100.00 0.00 100.00

When you click the checkbox, the AfterUpdate changes it to:

InvTotal OrigBalance PmtAmt NewBalance
100.00 100.00 100.00 0.00

If you then uncheck, you zero out the PmtAmt field and reset
NewBalance to the same as OrigBalance.

OrigBalance is not displayed in the apply payments form. See:

http://www.bway.net/~dfassoc/Park/Ap...sCustomer.html

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #3
----- Original Message -----
From: "David W. Fenton" <dX********@bway.net.invalid>
Newsgroups: comp.databases.ms-access
Sent: Wednesday, November 05, 2003 6:58 PM
Subject: Re: saving calculated values

Er, not in the case of an apply payments temporary table, which is
what he's working on.

I do this with a checkbox field. You click the checkbox and the
AfterUpdate of the checkbox sets the balance and payment fields.
Because of that, you need an original balance field so you can
revert to it if you uncheck the invoice.

Say you have this:

InvTotal OrigBalance PmtAmt NewBalance
100.00 100.00 0.00 100.00

When you click the checkbox, the AfterUpdate changes it to:

InvTotal OrigBalance PmtAmt NewBalance
100.00 100.00 100.00 0.00

If you then uncheck, you zero out the PmtAmt field and reset
NewBalance to the same as OrigBalance.


That's what I have in mind David. But I must ask, what happen's if the case
is something like:

InvTotal OrigBalance PmtAmt NewBalance
100.00 100.00 0.00 100.00

And the payment is only $80.

Does the clicking the checkbox activate something to check to see if
NewBalance <= PmtAmt ??

-jeremy

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Stefanos | last post by:
Hi everybody, I need some help on calculated values in my database design. I'm creating an accounting / business management application with the usual modules like A/R, A/P, Inventory, etc. ...
1
by: SJH | last post by:
I have been given an older database and asked to make upgrades and what not. One interesting thing I have come across with the database is that it was at one time set up so one of the tables would...
0
by: Henry | last post by:
Hi Is there any good ideas how to update form vb code always after some values are changed / added by vb (not user). I have some code behind subforms vb and there are calculations behind...
2
by: Douglas Buchanan | last post by:
I set the OnExit property of the "Cost" field in subform "subJobDetail" to save the record (see below). Then I call a global sub to copy the )] calculated field to a field in the subform "subJob"....
1
by: douh | last post by:
I know that this is not the way, however I need to save certian calculated values so that they do not change over time, ie. new tax rates etc. This is for an invoice header and invoice subform. I...
1
by: tconway | last post by:
I have an Access program that displays Customer data into a form and OrderID data into a subform. The totals in the Subform are based on calculated fields, i.e. the Total Amount field Calculates...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
11
by: James Hallam | last post by:
I have read through all the past topics and couldn't find what I was after so... I am looking to store some calculated values (don't flame just yet, just read on!). I have an piece of code...
8
by: Gilberto | last post by:
Hello, I have created a query to help me calculate some total values i need for a report. In the query field i have the following: TCL1: Costing!*(Engineering!+Engineering!) The results...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.