473,756 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Saving data into a table field by a query calculation

135 New Member
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![Piece Cost ddp]*(Engineering![Level 1 Driver]+Engineering![Level 1 Passenger])

The results are calculated correctly for the report, however now i need this calculated values (from TCL1 on the query) to be stored in a table (COSTING) under the same field name (TCL1).

How can i do this???
Thank you
Sep 12 '07 #1
8 3662
mlcampeau
296 Recognized Expert Contributor
Gilberto, storing calculated values is really NOT a good idea. If you're interested why, check out Database Normalisation and Table structures . What is the reason for wanting to do this?
Sep 12 '07 #2
Gilberto
135 New Member
Gilberto, storing calculated values is really NOT a good idea. If you're interested why, check out Database Normalisation and Table structures . What is the reason for wanting to do this?
Thnks, i will read that document.

My reason to do this is to be able to easily create new reports and new queries and also so that i have an actual table with "products" where the user could see ALL their characteristics (so far it only stores "#units" and "price", and i would like to also store the calculation "#units * price", which i did with the query).

Thanks again
Sep 13 '07 #3
mlcampeau
296 Recognized Expert Contributor
Thnks, i will read that document.

My reason to do this is to be able to easily create new reports and new queries and also so that i have an actual table with "products" where the user could see ALL their characteristics (so far it only stores "#units" and "price", and i would like to also store the calculation "#units * price", which i did with the query).

Thanks again
Again, Gilberto, it is not a good idea to store calculated values. What if the price changes? You will also have to change all of the totals that were related to that particular price change. In a large database, it could be hundreds or even thousands of changes, where if you don't store the calculated value, you would only need to change the price. Same thing if you change the number of units. It's just bad practice in general.
But...if you are wanting to denormalize your database (which I strongly advise against) then you could always run an Update query. First add the new field to your table, then create the update query.
Sep 13 '07 #4
Gilberto
135 New Member
Again, Gilberto, it is not a good idea to store calculated values. What if the price changes? You will also have to change all of the totals that were related to that particular price change. In a large database, it could be hundreds or even thousands of changes, where if you don't store the calculated value, you would only need to change the price. Same thing if you change the number of units. It's just bad practice in general.
But...if you are wanting to denormalize your database (which I strongly advise against) then you could always run an Update query. First add the new field to your table, then create the update query.

Thanks i will definitely take this into consideration and try to figure out another way to achieve what i need.

Thank you for the repliesm
Gilberto
Sep 14 '07 #5
Weise
11 New Member
Iam Having a similar problem and am trying to think how i can get around this. My scenario is thus; Iam building a DB for a friend who owns a garage. Basically they want a DB that can track all clients/vehicles & warrant of fitness/service Dates which will then lead to emailing / posting reminders to their customers when a new Warrant/Service is Due. I have setup Employee/Client/Vehicle/Job Tables for this purpose and have created relationships and made a form below:

, the [NextWarrantDate] is calculated based on the formula dateadd("m",[WarrantTerm],[NewWarrantDate])and seems to work fine.However I can't seem to get it to update the [VehicleWarrantE xp] in the [VehicleDetailsT able] (Highlighted in Green) Can anyone help me to get this to work I have spent 10+ hours reading several 100 pages of text and have now gone partially blind in my left eye , Jokes. Iam determined to somehow get this to work. Once I have Completed this task I need to setup some Queries and then figure out how to send Mass mail via outlook to the Respective Clients which should be even more entertaining VBA yay me.
Thank you
Jun 14 '10 #6
Weise
11 New Member
@Weise
Appended

Bob Olston from allexperts.com replied.

ANSWER: To reference a control on the Main form from a subform:
Forms!MainFormN ame!ControlName

YOu could also use

me.parent.contr olname
---------------------------------------------------

However

Iam getting a number of errors trying all different ways to implement it
Also I have attached a Second image to maybe help clear things up a little.

In First Image there are 3 Forms , The Main form is ClientForm with a subform named VehicleForm and the 3rd which is a subform within the (VehicleForm) is called JobForm (these are from Left to Right in attached image 1)

ok the VehicleForm contains all relevant data for any registered Vehicle including the vehicles Warrant of Fitness Expiry Date.<< This field/control I need to update Via the JobForm.. Which will Calculate a new Date based on a Date Entered into the NewWarrantDate field in the JobForm.
When a user clicks on the [Update] button I would like the [NewWarrantExpir y] Date to be saved back to the VehicleForm/Table and update the [VehicleWarrantE xp] to the new calculated date from the JobForm.



[mistake in image - details below]


[NewWarrantDate] in the [TextBox] in the attached image is supposed to be [NextWarrantDate]Which is actually just a Calculation based on [NewWarrantdate]+[WarrantTerm]in Months using the following input: =Dateadd("m",[WarrantTerm],[NewWarrantDate])
Jun 14 '10 #7
Weise
11 New Member
Ok I have found the solution Thanks to Bob Olston from allexperts.com.

Bob replied with the following;

As I told you previously, you can refer to a control on a form that is the top level form via this syntax

Forms!>formname >!<controlnam e>

So if NewWarrantExpir y is a control in the Vehicle form, you can update it via

Forms!Vehiclefo rm!newwarrantex piry = me.newwarrantda te

Some free Access training is listed here:

http://webpages.charter.net/bobalsto...line_Tutorials

and good bebinner books

http://databases.about.com/od/tutori...ccessbooks.htm


Also Google searches that begin with Microsoft Access xxxxxxxxxxx
or
Microsoft Access vba xxxxxxxxx

Can often get you more immediate help.

HTH

Bob
--------------------------------------------

My Attempt

From this I done the following to update the [VehicleTable].

I opened the [VehicleForm] , then switched to design view.

I Double clicked the [update] button which brings up the ButtonPropertie s.

under the [events] tab I created a new [Event Proceedure] for the button.

in the subsequent vba dialog I entered the following code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub UpdateWarrant_Click()
  2. On Error GoTo Err_UpdateWarrant_Click
  3.         Forms!Vehicleform!VehicleWarrantExp = DateAdd("m", [WarrantTerm], [NewWarrantDate])
  4.  
  5. Exit_UpdateWarrant_Click:
  6.     Exit Sub
  7.  
  8. Err_UpdateWarrant_Click:
  9.     MsgBox Err.Description
  10.     Resume Exit_UpdateWarrant_Click
  11.  
  12. End Sub
This has indeed updated the fields in Question from within the [Vehicleform] however when run from the within the [ClientForm] which is the Parent for the [VehicleForm] I get an error stating that [VehicleForm] "Can-not be found" :/

Yes I have tried
Expand|Select|Wrap|Line Numbers
  1. Forms!ClientForm!VehicleForm!VehicleWarrantExp = 
  2.  
as well as ;

Expand|Select|Wrap|Line Numbers
  1. Forms!ClientForm.VehicleForm!VehicleWarrantExp=
Nearly there
Jun 15 '10 #8
Weise
11 New Member
Finally Resolved in the post below:

Subform
Jun 15 '10 #9

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

Similar topics

2
1955
by: maceo | last post by:
I have a script that will print out the results of a table and make a calculation of a total of one of the columns. See example: <?php /* Database connection */ include(MYSQL_CONNECT_INCLUDE); /* Select all pilots */ $query = "SELECT * FROM pilots ORDER BY pilot_num ASC";
3
5330
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 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...
3
2577
by: brian kaufmann | last post by:
Hi, I had sent this earlier, and would appreciate any suggestions on this. I need to make calculations for unemployment rate for three different data sources (A,B,C) for many countries and age groupings. The calculation is: unemployment rate = number of unemployed/number of labour force
0
1865
by: leavandor | last post by:
I am trying to design a query that works with a relationship between a Table and a Query. I am comparing a value in the table with a computed value inside the query. The reason for this is that the Query calculates a field to become identical to the corresponding table field, for instance: Table 1 contains field "ID", which is WV008A00 Table 2 contains field "ID In", which is WV001000
1
1901
by: Paul H | last post by:
Say I have a table called tblPeopleInfo, one of the fields in the table is called FavouriteFruit. The FavouriteFruit field is a lookup field and will contain Apples, Oranges, Grapes etc..The list can be added to by users of the database. What is the best way to construct this lookup? Should it lookup a Table/Query or a Value List? If it looks up to a Table/Query should the lookup table just have a single "text" field or should it have...
18
3799
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 trouble. I have tried keeping some of the fields bound and when I use the save button it has been saving as 2 different records. This is unacceptable. This is what I have, can anyone help me out with this?
9
3136
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to be inserted into a standard web address in the table (the filed name is link) in ddw1 Example address ---
8
3273
by: mlwerth | last post by:
Dear Access Group: This is the most basic and most embarrassing of questions, but I cannot find where to change the data type of a text field that I have in Access 2003 to a number field. I've searched high and low through help databases and on the internet. The directions say to : Open the table in Design view Click the Data Type column of the field you want to change, click the
4
2033
by: trixxnixon | last post by:
i have a field on a form where a calculation is displayed. The field calculates the number of business days a request is due based on a priority level chosen from a drop down box. i want to save the data in the calculated field on the form to a new field in the table that i recently created to store this number. how would could i have this data save to this field when the form is saved?
0
9431
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9255
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9844
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9819
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9689
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8688
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7226
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5119
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3780
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.