473,550 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

67 New Member
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 1697
Jerry Maiapu
259 Contributor
@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
Bigdaddrock
67 New Member
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 Contributor
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
Bigdaddrock
67 New Member
@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 Contributor
@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
9219
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 is entered, either from a form or from the table view of the table, when the record gets saved it immediately displays #DELETED# in all of the...
1
4652
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 event of the form. Each record in the continous form should have different results for the same query. My query bases the results on a Where...
6
3785
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 you enter data to the first field on the main form (a VIN#), that is not the case. The SubForm control becomes disabled and will not accept the...
1
1255
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 automatically update the second table's record with the appropriate MgmtRevID? I can trigger code execution with the After Update property in a field...
2
2545
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 has alot of basic client information in it, nothing fancy, no code (other than what access has put in). I have created a second form "newVisit" ...
4
6561
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 to be able to automatically populate a "generic" schedule for a few weeks or more at a time. The schedule table contains: (pk) schedule_id,...
1
1513
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 have this info so you can see what I am attempting.) I have been tasked with a project where my users want to be able to enter several pieces of...
7
13497
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 form, in the top corner, I placed 4 unbound text boxes that displays summary information. On one of them, "TxtBudGWP" I want to display the specific...
1
1292
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 would then like the table to populate with the years for the next 5, each with a new user I.D. on button press for example. e.g. ID Year 1 2003...
0
1247
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 am trying to write some code behind a button on a form called "Membership & Fee Stats" which navigates to the associated Client record on the Clients...
0
7765
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8001
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...
1
7520
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...
1
5404
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...
0
5129
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3533
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...
0
3519
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1096
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
802
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.