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

3 tables, 1 calculated value

Hello all. I'm having a bit of a problem. I'm using Ms Access 2003.
I have 3 tables. Incoming Products, Outgoing Products, and Products In Stocks.
Lets say I have 25 of product A in the Products In Stock table. If I add in the table of the incoming products that I have 10 new incoming product A, how can I make it so that it adds +10 to product A in the Products In Stocks table?
May 13 '08 #1
3 1287
patjones
931 Expert 512MB
Hello all. I'm having a bit of a problem. I'm using Ms Access 2003.
I have 3 tables. Incoming Products, Outgoing Products, and Products In Stocks.
Lets say I have 25 of product A in the Products In Stock table. If I add in the table of the incoming products that I have 10 new incoming product A, how can I make it so that it adds +10 to product A in the Products In Stocks table?
How are you interacting with your tables? (i.e. forms with text boxes, etc.) If you're doing this in Visual Basic it shouldn't be too bad. Let me know a few more specifics and hopefully we can attack this problem...

Pat
May 13 '08 #2
How are you interacting with your tables? (i.e. forms with text boxes, etc.) If you're doing this in Visual Basic it shouldn't be too bad. Let me know a few more specifics and hopefully we can attack this problem...

Pat
yes, i am using forms to do them. i don't know vb at all, which makes things really hard for me, however i do know sql.
here are my tables:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Table Name =  Products In Stock
  3. Field ; Type ; IndexInfo
  4. codep ; text ; primary key
  5. namep ; text
  6. quantstock ; number
  7. price ; currency
  8. namem ; text ; reference key for manufacturer
  9.  
  10. Table Name =  Incoming Products (Bought products)
  11. Field ; Type ; IndexInfo
  12. codec ; text ; primary key with codep
  13. codep ; text ; primary key with codec
  14. quantity ; number
  15. (i designed it in a way that there can be many lines with the same product, since a product can be brought it several times)
  16.  
  17. Table Name =  Outgoing Products (Sold products)
  18. Field ; Type ; IndexInfo
  19. codec ; text ; primary key with codep
  20. codep ; text ; primary key with codec
  21. quantity ; number
  22. (here is the same as the second table)
  23.  
what i had in mind was that when the user opens up a certain product in the form for Products In Stock, the forms then searches for Incoming and Outgoing products A and then subtract both their quantities from each other. Thus the user doesn't have to touch the "quantstock", so I was thinking i should probably remove it.
what i can't figure out is how to make the form look automatically for the same product in the other 2 tables.

Thanks for trying to help ^__^
May 14 '08 #3
patjones
931 Expert 512MB
Might it be possible to use the SUM function in SQL? In other words, to get the sum of all incoming products with a certain "codep" you could try something like:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT SUM(quantity) FROM [Incoming Products] WHERE codep= "product A"
  3.  
And for the outgoing products:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT SUM(quantity) FROM [OutgoingProducts] WHERE codep= "product A"
  3.  
Then you could subtract outgoing from incoming, and you would have the result that needed to be added to what you have in stock and displayed on the form. If I'm not mistaken, you can use the Control Source property of a text box to assign it just such a calculated value...

Pat
May 14 '08 #4

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

Similar topics

7
by: Gb | last post by:
Hi There, I have: select myTable.*, Case When myTable.problem_CLOSE_date = myTable.problem_creation_date then 2 When myTable.problem_CLOSE_date >0 and myTable.problem_status='C' then 3...
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...
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...
3
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...
4
by: Krzysztof Bartosiewicz | last post by:
Hi! I haven't been using Access for a very long time and I forgot everything :) I will be very greatful for help since I have been fighting with this problem for a few hours... I have three...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
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...
3
by: meeraguna | last post by:
We have 20 -30 normalized tables in our dartabase . Also we have 4 tables where we store the calculated data fron those normalised tables. The Reason we have these 4 denormalised tables is when we...
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...
7
by: sparks | last post by:
I am working on a database that has a lot of calculated values on the forms. These were never put into the tables. But were tied to unbound fields on the forms. Now 8000 records later they want...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.