aman909
06-20-2007, 01:43 AM
Hi,
Im trying to create a database for a stock control system. I have a slight problem, the stock is in two places. So what i have to do is put in the values of stock in each place and then display the value of those two added up in the table. What is the best way to be able to do this?
Newman
06-20-2007, 02:26 AM
It is important that you do not create a calculated field in your table. If you can get a data using others, then that data should not be stored. The use of a query will get you the data needed.
ColinEssex
06-20-2007, 02:27 AM
You don't need to store the value in a table.
Just calculate the stock level in a query when you need it
Col
neileg
06-20-2007, 02:36 AM
A friendly warning! Stock control (or inventory as our colonial cousins call it) is deceptively complex. Do a search in these forums for stock control or inventory. You will find lots of help and advice. Don't repeat the mistakes that many others have aleady made!
Good luck!
aman909
06-20-2007, 02:54 AM
i have now created a query but it still wont work. For the total i have used this,
"number1"+"number2"
number 1 and 2 are the field names i have used. But it still wont add the two values up that there in those columns. What do you suggest?
ColinEssex
06-20-2007, 03:01 AM
Use the Sum() function
Col
aman909
06-20-2007, 03:50 AM
i have used this,
SELECT SUM (number1, number2) as "total"
but i still cant get it to work. can you please help.
neileg
06-20-2007, 03:52 AM
Are [number1] and [number2] both fields in the record?
aman909
06-20-2007, 03:53 AM
yeh number 1 and number 2 are the field names in the table
Newman
06-20-2007, 05:16 AM
Can you post your whole SQL string, exactly as you wrote it in your database, so that we can take a look at it?
aman909
06-20-2007, 05:26 AM
SELECT SUM (number1, number2) as "total"
FROM stock
that is what i have tried to use.
i have also just tried
=Sum([number1]) + ([number2])
but that didnt work
Simon_MT
06-20-2007, 05:43 AM
What was the result of the calculation vs what it should have been?
Newman
06-20-2007, 05:43 AM
These should do the job...
SELECT Sum([number1]+[number2]) AS total
FROM stock;
or
SELECT Sum([number1])+ Sum([number2]) AS total
FROM stock;
Edit: Maybe someone could tell which one would be faster. I would go with the first one since it has only one function called, but I haven't tested it.