AlvaroCity
Registered User.
- Local time
- Today, 18:18
- Joined
- Jul 16, 2016
- Messages
- 70
Hi there.
I bumped into a problem while programming.
I firstly have to say that I'm not a professional programmer so I have been doing all this on the go.
I have a DB for a company. I create dispatches notes to pressing a button and it also updates the stock.
Sometimes, for unforeseen reasons, the number of units displays on the dispatch note is higher than the actual stock. That's not a problem as I know for sure that I have the necessary stock in the company.
The problem comes up when the programme updates the stock. When the units displays on the dispatch note is higher than the stock, the SQL does not update properly and leaves the stock as it is instead of leaving the stock at zero.
Example:
I have 2 units on stock and I create a dispatch note for 4 units. When updating the stock instead of 0 units for stock, the program keeps the 2 units.
I think what I need is to use "CASE" or "IF" but I dont know how. I hope you guys can help me with this.
I bumped into a problem while programming.
I firstly have to say that I'm not a professional programmer so I have been doing all this on the go.
I have a DB for a company. I create dispatches notes to pressing a button and it also updates the stock.
Sometimes, for unforeseen reasons, the number of units displays on the dispatch note is higher than the actual stock. That's not a problem as I know for sure that I have the necessary stock in the company.
The problem comes up when the programme updates the stock. When the units displays on the dispatch note is higher than the stock, the SQL does not update properly and leaves the stock as it is instead of leaving the stock at zero.
Example:
I have 2 units on stock and I create a dispatch note for 4 units. When updating the stock instead of 0 units for stock, the program keeps the 2 units.
I think what I need is to use "CASE" or "IF" but I dont know how. I hope you guys can help me with this.
Code:
Ssql = "UPDATE (tblPiezas INNER JOIN tblPedidoDetalle ON tblPiezas.[PiezaID] = tblPedidoDetalle.[PiezaID]) INNER JOIN tblpedidodetallealbaran ON tblPedidoDetalle.[PedidoDetalleID] = tblpedidodetallealbaran.[PedidoDetalleID]" & _
"SET tblPiezas.Stock= [Stock]-[NumeroPiezas]" & _
"WHERE (((tblpedidodetallealbaran.AlbaranID)=" & StrAlbaran & "));"