473,387 Members | 1,624 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.

Can I populate a table's record from a calculation based on entries on a form?

I have two entries on an Invoice form: PRICE and QUANTITY (as well as the INVOICE NUMBER).
In creating a new INVOICE I am pulling in a product's PRICE from a table (though the price may change down the road). On the same form I am entering the QUANTITY of the item being bought. I would like to store the resultant COST (PRICE X QUANTITY) in a table containing the INVOICE NUMBER, QUANTITY, PRODUCT, and COST.
Any suggestions as to how I might enable the data entry person to just enter the PRICE and QUANTITY on the form, yet record both QUANTITY and COST along with the Invoice Number in an INVOICE TABLE?
Note, the prices of the products change over time, so the INVOICE's record must reflect the COST of the product at the time it was issued (and not change later just because the price changes).
Jun 21 '10 #1
5 1692
Jerry Maiapu
259 100+
@Bigdaddrock
Ok database rule does not allow storing of calculated results in the table though it is possible.
You can create a query to do calculations.
Then a form or report can be created based on these queries.

Ok if you just want view the result (cost) on the form then just create an unbound textbox and on the record source put;
Expand|Select|Wrap|Line Numbers
  1. =[name of Quantity text box]*[name of Price text box]
However, for convenience use a query to do so: Create a query based on your table and select the necessary fields including Price and Quantity and use this format in a new column of the query:
Expand|Select|Wrap|Line Numbers
  1. COST: [Price]*[Quantity]
Set you form's record source to the query and create a text box and set its record source to COST.

Hope this helps..
Jun 22 '10 #2
A query would be dynamic in that it would compute the cost at whatever the price happens to be at the time it is run. Since the prices change over time, the computed cost would differ from the originally posted cost.
Unless you are suggesting that there is a way to utilize a query to post the result to a table, your suggested response will not suffice.
Jun 22 '10 #3
Jerry Maiapu
259 100+
Well ,then you can make use of recordset in VBA by calculating and inserting direct into the desired table from the form.
Jun 22 '10 #4
@Jerry Maiapu
I am a bit of a novice when it comes to VBA. But I will give it a try. Any suggestions on how I would phrase it in the Recordset??
Thanks
Jun 22 '10 #5
Jerry Maiapu
259 100+
@Bigdaddrock
I posted a solution to a similar question half an hour ago here: Solutuion; See Post#9

If you have any questions with respect to my solution do post it.

Hope this helps

Jerry
Jun 23 '10 #6

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

Similar topics

8
by: Bri | last post by:
Greetings, I'm having a very strange problem in an AC97 MDB with ODBC Linked tables to SQL Server 7. The table has an Identity field and a Timestamp field. The problem is that when a new record...
1
by: Kevin.S.Campbell | last post by:
Greetings, I'm trying to run a sql query on a continous form. I have the query working correctly the way I want it. I want this query to be displayed on the form in the text box on the load...
6
by: MLH | last post by:
When the vehicle entry form (frmVehicleEntryForm) first opens, the additional owner SubForm control (frmAddnlOwnrListSubForm) is enabled. You can click on it and it will accept the focus. But after...
1
by: Robert Waggoner | last post by:
I have a table with MgmtRevID and MgmtRevDate I have another table that requires the MgmtRevID to be selected each time a record is created. Access 97 database How can I write code that will...
2
by: whitc26 | last post by:
Let me preface: I'm a novice, and have no programming experience. I have created an access database and have a few tables in it. I have created a form called "clients" This form opens up and...
4
by: Nate | last post by:
I am looking to populate a Schedule table with information from two other tables. I am able to populate it row by row, but I have created tables that should provide all necessary information for me...
1
by: Birky | last post by:
I am truly stuck and need some help on how to put this form together; any help or suggestions you can provide would be greatly appreciated. (Sorry this one is so long but I believe it is necessary to...
7
kcdoell
by: kcdoell | last post by:
Hello: I have a continous form that displays various forecasting records that an End user can add or edit the records (this feeds off of a query that I created called "ReQryForecast"). On that...
1
by: zoeb | last post by:
Hi, I'm very new to writing databases using VBA and I'm sure this is relatively simple to solve. I have a table called tblYear and the user enters a value of a year from a form e.g. 2003. I...
0
by: emrodge | last post by:
Hi, Any help appreciated on this one. I've set up a simple database with 4 tables & 3 forms. The tables link together on a field called "client id" which is the ID in a table called "Clients". I...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.