473,394 Members | 1,641 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,394 software developers and data experts.

Saving calculated field from a Form into a table

We have a form that contains a calculated field ( the total price of restaurant order), and we want to save the value from the calculated field into it's table.

**Note:
this form is from TXN table and it has a subform as you can see from ORDER table.



Attached Images
File Type: jpg Capture1.jpg (78.5 KB, 3289 views)
File Type: jpg Capture2.jpg (253.8 KB, 2856 views)
File Type: jpg Capture3.jpg (105.9 KB, 3233 views)
Aug 8 '18 #1
5 6746
zmbd
5,501 Expert Mod 4TB
AlbaraaF
While this can be done, the usual recommendation is against storing calculated values.

If you need the calculation for a report then I suggest that you move your form's record source into a stored query, include the calculated value as one of the calculated field.

Looks like you are simply calculating an invoice total?
Aug 8 '18 #2
NeoPa
32,556 Expert Mod 16PB
Hi.

Instead of using a formula on your Form for the calculated total, you should have a bound Control that gets updated whenever you enter or change the pertinent data on the Form. Does that make sense?
Aug 8 '18 #3
NeoPa
32,556 Expert Mod 16PB
It looks like I cross-posted with Zmbd.

The points he makes about storing calculated values are worth considering. One of the frequent exceptions to this 'rule' is with invoice values, due to prices fluctuating over time and the calculated result being impossible, or sometimes just very difficult, to reproduce reliably.

It's worth making sure how this fits with your own database design. If it's possible to reproduce the calculations reliably, even at a very much later date, then it's not advisable to store the result at all.

However, if you do need to do so, my earlier advice shows you how best to do that.
Aug 8 '18 #4
zmbd
5,501 Expert Mod 4TB
NeoPa,
One workaround I have done with fluctuating pricing is to store the price at time of purchase/sale. Same thing with discounts on pricing.

What do you think about something along these lines (very simplified - I haven't included shipping, taxes, fees, etc...):
[Prts]
[PK][FK_Spplyr][SpplyrPrtNum][PrtsDscrptn]

[PrtPrchs]
[PK][FK_Parts][PrcsAtPrchs][DscntAtPrchs]

[Invoice]
[PK][InvDate][FK_PrchOrdr][FK_PrtPrchs][UnitOrdrd][UntsRcvd]

The query against the "purchase order (PO#)" (or the "invoice number" should more than one PO# be allowed per invoice, something my company doesn't allow but others may) to pull the invoice together for the total pricing.
Aug 9 '18 #5
NeoPa
32,556 Expert Mod 16PB
That can work Z. I only say that sometimes there are exceptions. Each exception can have alternative solutions, and yours minimises the non-normalised data, but not everyone wants to handle such complicated situations.

I think mostly, as well as warning of some of the possible problems, we should answer the question directly. Although we're often more experienced in the technical side of the subject, we rarely have the full story that the OP has to deal with.
Aug 9 '18 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jeremy Weiss | last post by:
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...
14
by: Allen Browne | last post by:
Subform is based on a single-table query that contains a calculated field: Amount: Round(CCur(Nz(*,0)),2) Continuous subform displays this field in a text box named Amount. As user enters new...
3
by: Marina | last post by:
I am using Access 2002. I have a client transactions table with a field for HoursBilled, BillingRate, and AmountBilled. Amount Billed is a caluclation of HoursBilled * BillingRate. I can get...
1
by: john | last post by:
With the help of this NG I got the following to work in a calculated field in a form: =DCount("*";"MyTable1";"MyField1='abc' AND MyField2='J'") I would like to make another calculated field...
3
by: kelley.l.turner | last post by:
Hi all, I am very new to MS Access so please bear with me! I have created a simple calculated field in my data entry form, yet when I view my data table or try to generate a report based on...
4
by: debi.robarts | last post by:
Ok, in my database I have something like this: Date One # of Days to Next Date These calculate a field "Date Two." Because "Date Two" is an expression (calculated by the form), I can't set...
5
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public...
9
by: Haas C | last post by:
Hi all! Is there anyway I can override a value in a calculated field on a form? For example: I have a form which displays the following fields based on a query: Premium Due field has the...
3
by: Ciara9 | last post by:
I am having problems trying to update a field in a database using a field in a form. I currently have two fields, Today and Tomorrow in a table named Date. The Today field automatically defaults to...
9
by: fgsteward | last post by:
I have a calculated field in a form using this expression typed in the control source box =+ Since I cant bind this field to a table field I would like to transfer the value returned by this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.