473,406 Members | 2,698 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,406 software developers and data experts.

how to calculate sum for items that have the same id or the same serial number

elenaA
42
Hello

i have a table with some products. in the table i have two fields called itemIn ( buy) and Item out( sold).

now i want to calculate how many items with the same serial number or with the same id i have in stock.

example

ID date serial number ItemIn ItemOut Stock
1 20.05.2017 test1 55 20 35

i know how to calculate that

but lets say that another day i get new items with the same serial number

how to create field that will take the value from previus field and sum the new items so that i will have correct sum in the stock?

example

ID date serial number ItemIn ItemOut Stock
1 21.05.2017 test1 100 0 ?

correct way shuld be... the value from the stock and the new items that arrieved today

so the results shuld be 35+100 = 135, my new value of the items should be 135.

also i want if i sold some items that my value in the stock should change

exapmle

ID date serial number ItemIn ItemOut Stock
1 21.05.2017 test1 100 50 ?

the results should be 35 from stock +100 new items = 135 and 50 sold today ..the new value in the stock should be now 85

thanks in the advance


ID date serial number ItemIn ItemOut Stock
1 21.05.2017 test1 100 50 85
May 20 '17 #1

✓ answered by PhilOfWalton

Elena

Try
Expand|Select|Wrap|Line Numbers
  1. Nz(DSum("ItemIn", "MyTable", "Serial Number = " & Chr$(34) & [Serial Number] & Chr$(34))) - Nz(DSum("ItemOut", "MyTable", "Serial Number = " & Chr$(34) & [Serial Number] & Chr$(34)))
  2.  
Where "MyTable" is the name of your table

Phil

8 1557
PhilOfWalton
1,430 Expert 1GB
Can you please clarify what you mean by "with the same serial number or with the same id"

In your examples, ID = 1 has Serial Number "Test1". Is this always the case or could ID = 1 have a Serial Number "Test999"?

Phil
May 20 '17 #2
elenaA
42
well with my serial number i mean that the serial number has to be the same, and ID is chaning

example

ID Serial number
1 test1
2 test1
3 test1
4 test2
5 test3
6 test2
7 test3
8 test2
9 test4
10 test5
May 20 '17 #3
PhilOfWalton
1,430 Expert 1GB
So am I correct in assuming the ID is irrelevant and you want to do your calculation purely based on the Serial Number?

Phil
May 20 '17 #4
elenaA
42
yes that is correct

i try with query but i dint get the sum for the same serial number
May 21 '17 #5
PhilOfWalton
1,430 Expert 1GB
Elena

Try
Expand|Select|Wrap|Line Numbers
  1. Nz(DSum("ItemIn", "MyTable", "Serial Number = " & Chr$(34) & [Serial Number] & Chr$(34))) - Nz(DSum("ItemOut", "MyTable", "Serial Number = " & Chr$(34) & [Serial Number] & Chr$(34)))
  2.  
Where "MyTable" is the name of your table

Phil
May 21 '17 #6
elenaA
42
hello

i try but says me that i miss some operator
i think is missing some " or ), [, ] but i dont know where
May 21 '17 #7
PhilOfWalton
1,430 Expert 1GB
Can you please post back your code (Copy it directly)

Thanks

Phil
May 21 '17 #8
elenaA
42
hello

i resolve everythink. thank you very much
May 22 '17 #9

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

Similar topics

3
by: Niy | last post by:
what does that mean? what for? I searched a lot but failed to find explanation. Sometimes I really have difficulty finding documentation for some views.
15
by: tom | last post by:
Hi, How do I get the serial number of the harddisk in .NET? I want this to be the same number even if the user has reformatted, so I do not want the volume serial number. Thanx, t
5
by: | last post by:
Hi, Do memory sticks have serial numbers like harddrives? If so how can I get this, I want to uniquely identify a memory stick (removable drive) for authentication. Thanks
79
by: Klaus Bonadt | last post by:
In order to protect software from being copied without licence, I would like to use something like a key, which fits only to the current system. The serial number of the CPU or the current...
9
by: Nebojsa4 | last post by:
Hi. First, sorry on my weak English to all. Qusetion: How to read (in VB) Manufacturer serial number of Hard disk drive? Not volume/serial number of C:, D:, etc. partitons. For reading...
8
chandru8
by: chandru8 | last post by:
hi every body i need a logic , that for a particular code i need to genrate a serial number for a day should be one for the next day it should be increment to 2 like this can any one help me...
1
by: rajsrmc | last post by:
Hello Guys! I have a mysql table which is connected with aspx page in grid view, in the connected table i have assigned Serial number column as Primary key and as well in auto increment, by using...
0
Airslash
by: Airslash | last post by:
Hello, I've written a class that resembles a hard drive. I'm already able using the Windows API to get information such as the remaining free bytes, the sectors and clusters,a nd it all works...
1
by: Keshia | last post by:
I have a database that is for keeping track of inventory. I need to have my form for entering new inventory to automatically make a new serial number based on the category of the new item. The...
2
by: muhammadayub77 | last post by:
Hi I am using ms access 2013. Often in my organization an excel sheet with the data needs to be imported in ms access for official use. While creating reports before that i want a table to have a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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...
0
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...
0
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...

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.