Update stock data

Hello,
I am trying to build a pos and inventory system in vb 6.0 with MS-Access database. I do not have much experties in vb 6. Ok here is the question now, I have a frmcashsale in my system which have a MSHFlexgrid called grid, I have managed the codes to update the grid with invoice no, invoice date, product code, price, net amount and remarks columns. Also there is a sub total, Total and cash change txt boxes those are working fine. I have a cmdConfirm button in the from. What I now want is , after I complete the sales, I will click the cmdConfirm button and the following two things will happen :
1) Details of the sales will be updated in tblsales table (I think I can manage that) but the tough part is to calculate the profit. I want the price ( i mean sale price) will be deducted from the buy price (which is not stored in tblsales, stored in tblstock) and profit will be stored in tblsales for each row of MSHFlexgrid.
2) Stock will be updated as per the product code of the tblstock. There is a field in tblstock named on_hand which will deducted as per the sold no. of pcs of that product for each row of MSHFlexgrid..
I am using Ms-Access as database and VB 6.0 for programming. I will try to attach an image of my frmCashSales that will clear the matter very much I think.

sorry for the delay.
Yes I have two tables-tblstock-have all the stock details, tblsales-will have all the details of my sales."a call has to be made to tblstock to see how much of a unit is available. if available, sell the unit and update tblsales"
yes you are right."get price from tblstock, how many units sold, get total for THAT SPECIFIC sale?"
here I like to add some. not only the total also the profit from this sale. I mean :
Profit = ((sale price) x no. of units sold - ((buy price) x no. units sold )
here buy price (bprice) is in tblstock and no. of units sold along with sale price (sprice) is in tblsales. Profit will also be stored in tblsales. This sales price and profit will be store accordingly by the product code"update tblstock to deduct the sold units, update tblsales with the units bought AND a total? which total, ALL units or just that particular item?" update tblsales with the units sold. just that particular item with the unique product code.
I am trying to give an example :

Suppose the database have a product in tblstock in 5 pcs with code "67AENKalJKS12" sale price(sprice) $1,990.00 and buy price(bprice) is $1,400.00.
in the Cash sales from, a sales invoice no. will serially generate when the from is loaded (I am trying to code this thing). User will put "67AENKalJKS12" in the code box and press enter, sale price will be automatically shown in the sales price txt box. NO. of pcs (suppose 1) should be given and there is a add button which will add the item in a mshflexgrid (grid). after adding all the item, there is another button name "confirm sale" which will clicked to perform the final sale.
from the tblstock code "67AENKalJKS12' will be deducted by 1 and the field on_hand will show 4.
in tblsales code "67AENKalJKS12" will be shown with the no. of pcs. sold is 1, sales price is $1,990.00 and profit will be $590.00" (if there is no discount).
if 2 pcs sold, from the tblstock code "67AENKalJKS12' will be deducted by 2 and the field on_hand will show 2. the code "67AENKalJKS12" will be shown with the no. of pcs. sold is 2, sale price is ($ 1,990.00 x 2) and profit will be ($590.00 x 2)"

i have try to clear all the things. Waiting for your replay.
Again I am sorry for the delay.

But I am getting the following error message :
Run-time error '3201':
Either BOF or EOF is true, or the current record ahs been deleted. requested operation requires a current record.
in the following line :

Everything seems to be alright just the profit is not calculating, the sprice is storing in the field of rs!profit of tblsales. I don't know why. I have tried with xProfit1 and xProfit2 and with few other tricks but can't overcome it. My bprice is in tblstock, sprice is in the form which comes from tblstock and profit will be stored in tblsales under the field "profit". the interesting thing is I change it to "profit" but it automatically change to "Profit". I am clue less.

Hallo there
I have the same inventory system and I found this code but I have the same problem highlighted above of either BOF or EOF
I have tried to change as you have shown but am getting the same error message
Please Help

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...