Results 1 to 23 of 23

Thread: [RESOLVED] What's missing?

  1. #1

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Resolved [RESOLVED] What's missing?

    I have following textboxes: txtcode,txtsupply, txtdesc,and txtQty. I enter a code in txtcode and automatically the txtdesc will display item description and also the txtsupply will display the supply available (I'm getting the value from DB).

    I will type quantity to be sold in the txtQty and then click the additem button to add/display the said item in list of items to be sold using a listview. I have codes in my listview to allow me to double click any item for editing purposes (change the quantity to be sold i.e. from 5 and make it 2 or from 5 make it 10).

    Now my concerns is this when I double click an item the txtsupply value is not adding back 5 to the DB which should be reflected in txtsupply.

    Example:
    Supply = 105
    quantity to be sold = 5

    so when I click additem automatic 5 will be subracted from number of supply and become 100.

    I will double click the item in the listview txtsupply will still be 100 But supposedly it should display 105.

    What am i missing with my codes?
    VB Code:
    1. Private Sub txtCode_Change()
    2.   txtQty.Text = ""
    3.   txtDiscount.Text = ""
    4.  
    5.   If InStr(1, txtCode.Text, "*") = Len(txtCode.Text) Then
    6.     txtQty.SetFocus
    7.   End If
    8.  
    9.   If rsStocks.State = adStateOpen Then rsStocks.Close
    10.  
    11. On Error Resume Next
    12.   If txtCode.Text <> "" Then
    13.     rsStocks.Open "SELECT * FROM tblStocks WHERE Code = '" & txtCode.Text & "'", oConn, adOpenStatic, adLockOptimistic
    14.     If rsStocks.RecordCount <> 0 Then
    15.       txtSupply.Text = rsStocks.Fields("Quantity")
    16.       txtDesc.Text = rsStocks.Fields("ProductDescription")
    17.       'txtSellingPrice.Text = Format$(rsStocks.Fields("SellingPrice"), "P###,###,##0.00")
    18.     Else
    19.       txtSupply.Text = ""
    20.       txtDesc.Text = ""
    21.       'txtSellingPrice.Text = ""
    22.       txtSubTotal.Text = ""
    23.     End If
    24.  Else
    25.     txtSupply.Text = ""
    26.     txtDesc.Text = ""
    27.     'txtSellingPrice.Text = ""
    28.     txtSubTotal.Text = ""
    29.   End If
    30. End Sub
    31.  
    32.  
    33. Private Sub lstStocks_DblClick()
    34.   If lstStocks.ListItems.Count = 0 Then
    35.     Exit Sub
    36.   Else
    37.     edwin = lstStocks.SelectedItem.Index
    38.     txtCode.Text = lstStocks.ListItems.Item(edwin).Text
    39.     txtDiscount.Text = Val(lstStocks.ListItems.Item(edwin).SubItems(4)) '/ Val(lstStocks.ListItems.Item(edwin).SubItems(2))
    40.     txtQty.Text = lstStocks.ListItems.Item(edwin).SubItems(2)
    41.     txtSellingPrice.Text = Val(lstStocks.ListItems.Item(edwin).SubItems(3))
    42.     'iQtyTemp = txtQty.Text
    43.    
    44.     sSQL = "UPDATE tblStocks SET Quantity = Quantity + " & txtQty.Text & " WHERE [Code]= '" & (lstStocks.ListItems.Item(edwin).Text) & "'"
    45.     oConn.Execute sSQL
    46.     Debug.Print sSQL
    47.     Debug.Print rsStocks.Fields("quantity")
    48.     lstStocks.ListItems.Remove (edwin)
    49.     txtCode.Locked = True
    50.    
    51.     cAmountDueTemp = 0
    52.     For i = 1 To lstStocks.ListItems.Count
    53.       cAmountDueTemp = CCur(cAmountDueTemp) + CCur(lstStocks.ListItems.Item(i).SubItems(5))
    54.       txtAmountDue.Text = cAmountDueTemp
    55.     Next
    56.     lstStocks.Enabled = False
    57.   End If
    58. End Sub
    59.  
    60.  
    61. Private Sub cmdAddItem_Click()
    62.   Dim lst As ListItem, itemFound As ListItem
    63.  
    64.   If txtCode.Locked = True Then
    65.     txtCode.Locked = False
    66.   End If
    67.  
    68.   If lstStocks.Enabled = False Then
    69.     lstStocks.Enabled = True
    70.   End If
    71.  
    72.   'If rsStocks.State = adStateOpen Then rsStocks.Close
    73.   'rsStocks.Open "SELECT * FROM tblStocks WHERE Code = '" & txtCode.Text & "'", oConn, adOpenStatic, adLockOptimistic
    74.      
    75.   '=====================================================================
    76.   '= The above commented code is the same with the enclosed code below =
    77.   '=====================================================================
    78.   '####################################################################
    79.   sSQL = "SELECT * FROM tblStocks WHERE [Code] = '" & txtCode.Text & "'"
    80.  
    81.   If rsStocks.State = adStateOpen Then rsStocks.Close
    82.   rsStocks.Open sSQL, oConn, adOpenStatic, adLockOptimistic
    83.   '#####################################################################
    84.   If CheckNullValue = False Then Exit Sub
    85.   If Compare = False Then Exit Sub 'or If Not Compare Then Exit Sub
    86.  
    87.   If Val(txtQty.Text) > Val(txtSupply.Text) Then
    88.     Call msgSupply
    89.     txtQty.SetFocus
    90.     SendKeys "{home}+{end}"
    91.     Exit Sub
    92.   'End If
    93.  
    94.   ElseIf txtQty.Text <> 0 Then
    95.   'Set itemFound = lstStocks.FindItem(txtCode.Text)
    96.   'If itemFound Is Nothing Then
    97.     cAmountDueTemp = 0
    98.     If txtDiscount.Text = "" Then
    99.       txtDiscount.Text = 0
    100. '      cSubtotal = (val(txtQty.Text) * CCur(rsStocks.Fields("SellingPrice")))
    101.       cSubtotal = (Val(txtQty.Text) * Val(txtSellingPrice.Text))
    102.       cMargin = (Val(txtSellingPrice.Text) * Val(txtQty.Text)) - (rsStocks.Fields("PurchasePrice") * Val(txtQty.Text))
    103.     Else
    104.       'iTempSubTotal = (Val(txtQty.Text) * Val(rsStocks.Fields("SellingPrice"))) - (Val(txtQty.Text) * (Val(txtDiscount.Text)))
    105. '      cSubtotal = (val(txtQty.Text) * val(rsStocks.Fields("SellingPrice"))) - (Val(txtQty.Text) * (val(txtDiscount.Text))) 'Val(iTempSubTotal))
    106.       cSubtotal = (Val(txtQty.Text) * Val(txtSellingPrice.Text)) - (Val(txtQty.Text) * (Val(txtDiscount.Text))) 'Val(iTempSubTotal))
    107.       cMargin = (Val(txtSellingPrice.Text) * Val(txtQty.Text)) - Val(txtQty.Text) * Val(txtDiscount.Text) - (rsStocks.Fields("PurchasePrice") * Val(txtQty.Text))
    108.     End If
    109.  
    110.     'rsStocks.Fields("Quantity") = (Val(rsStocks.Fields("Quantity") + Val(iQtyTemp)) - Val(txtQty.Text))
    111.     'rsStocks.Update 'Update the database
    112.    
    113.     'Check if it's time to order the item
    114.     If rsStocks.Fields("Quantity") <= rsStocks.Fields("ReOrder") Then
    115.       MsgBox rsStocks.Fields("ProductDescription") & " Product" & _
    116.       Chr(13) & "has reached its Re-order Point", vbInformation, ProgName
    117.       txtQty.SetFocus
    118.     End If
    119.  
    120. '    sSQL = "UPDATE TblStocks SET Quantity = Quantity + " & iQtyTemp & " - " & Val(txtQty.Text) & " WHERE [Code]='" & txtCode.Text & "'"
    121.     sSQL = "UPDATE TblStocks SET Quantity = Quantity  - " & Val(txtQty.Text) & " WHERE [Code]='" & txtCode.Text & "'"
    122.     oConn.Execute sSQL
    123.    
    124.     Set lst = lstStocks.ListItems.Add(, , txtCode.Text) 'DISPLY IN LISTVIEW
    125.       lst.SubItems(1) = txtDesc.Text
    126.       lst.SubItems(2) = txtQty.Text
    127. '      lst.SubItems(3) = Format$(rsStocks.Fields("SellingPrice"), "###,###,##0.00")
    128.       lst.SubItems(3) = Format$(Val(txtSellingPrice.Text), "###,###,##0.00")
    129.       lst.SubItems(4) = Format$(Val(txtDiscount.Text), "###,###,##0.00")
    130.       lst.SubItems(5) = Format$(CCur(cSubtotal), "###,###,##0.00")
    131.       lst.SubItems(6) = Format$(rsStocks.Fields("PurchasePrice"), "###,###,##0.00")
    132.       lst.SubItems(7) = Format$(CCur(cMargin))
    133.    
    134.     txtCode.Text = ""
    135.     txtDiscount.Text = ""
    136.     txtQty.Text = ""
    137.     txtSellingPrice.Text = ""
    138.     txtCode.SetFocus
    139.  
    140.     For i = 1 To lstStocks.ListItems.Count
    141.       cAmountDueTemp = CCur(cAmountDueTemp) + CCur(lstStocks.ListItems.Item(i).SubItems(5))
    142.       txtAmountDue.Text = Format$(cAmountDueTemp, "###,###,##0.00")
    143.     Next
    144.   Else
    145.     MsgBox "Quantity must not be zero", vbInformation, ProgName
    146.     txtQty.SetFocus
    147.     SendKeys "{home}+{end}"
    148.   End If
    149.  
    150.   Set lst = Nothing 'destroy the list
    151.  
    152. '  Else
    153. '    MsgBox "Product code already exists in the list.", vbInformation
    154. '    txtCode.Text = ""
    155. '    txtDiscount.Text = ""
    156. '    txtQty.Text = ""
    157. '  End If
    158.  
    159. End Sub
    Last edited by Simply Me; Jul 27th, 2006 at 09:38 AM.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  2. #2

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's is missing?

    Im sorry for the change of topic title. I double check my code and UPDATE is actually updating but i cant display the updated value in my txtsupply.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  3. #3
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: What's is missing?

    im not sure you can do it like that

    UPDATE TblStocks SET Quantity = Quantity - " & Val(txtQty.Text) & "

    if u already have the quantity in your app do the math and put the new value in.

    UPDATE TblStocks SET Quantity = "Supply - Val(txtQty.Text) & "....

    get it?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: What's is missing?

    is missing vbcode tags

    pete

  5. #5

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's missing?

    Quote Originally Posted by westconn1
    is missing vbcode tags

    pete
    I just edited my first post and added the vbcode tag

    Quote Originally Posted by Static
    im not sure you can do it like that
    it can be done and its working fine with me. Its just that i cant display the correct value in my textbox but when i checked my DB the value is actually added back.
    Last edited by Simply Me; Jul 27th, 2006 at 09:48 AM.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: What's missing?

    ok, well after the update, requery the field?
    or just do the math in your app and change the field...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's missing?

    i did something like this and its not working.
    VB Code:
    1. sSQL = "UPDATE tblStocks SET Quantity = Quantity + " & txtQty.Text & " WHERE [Code]= '" & (lstStocks.ListItems.Item(edwin).Text) & "'"
    2.     oConn.Execute sSQL
    3.     rsStocks.Requery
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  8. #8
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: What's missing?

    are your text fields bound to rsStocks?

    if not u have to reset then

    txtWhatever = rs!whatever
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  9. #9

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's missing?

    in my code, everytime the change event of txtcode is triggered the txtsupply gets its value from my DB.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  10. #10

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's missing?

    anyone here?
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  11. #11

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's missing?

    bump
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  12. #12
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: What's missing?

    Quote Originally Posted by Simply Me
    I double check my code and UPDATE is actually updating but i cant display the updated value in my txtsupply
    Quote Originally Posted by Simply Me
    in my code, everytime the change event of txtcode is triggered the txtsupply gets its value from my DB.
    I hope you want to display the updated qty in the txtSupply after the update query gets displayed...where are you requerying the value again after your update query...post the codes...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  13. #13

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's missing?

    Quote Originally Posted by ganeshmoorthy
    I hope you want to display the updated qty in the txtSupply after the update query gets displayed...where are you requerying the value again after your update query...post the codes...
    I posted the code in post #7. I want to display the updated quantity in txtsupply.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  14. #14
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: What's missing?

    could you post the full code...including the codes where you display the updated value to the text box...just requerying alone will not help you...if you have to code to display your records in txtCode_Change, call it again or write
    VB Code:
    1. rsStocks.Open "SELECT * FROM tblStocks WHERE Code = '" & txtCode.Text & "'", oConn, adOpenStatic, adLockOptimistic
    2.     If rsStocks.RecordCount <> 0 Then
    3.       txtSupply.Text = rsStocks.Fields("Quantity")
    4.       txtDesc.Text = rsStocks.Fields("ProductDescription")
    5.       'txtSellingPrice.Text = Format$(rsStocks.Fields("SellingPrice"), "P###,###,##0.00")
    6.     Else
    7.       txtSupply.Text = ""
    8.       txtDesc.Text = ""
    9.       'txtSellingPrice.Text = ""
    10.       txtSubTotal.Text = ""
    11.     End If
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  15. #15

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's missing?

    the full code is in post #1.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  16. #16
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: What's missing?

    if you are updating the records you must call the function where you are displaying the values...do you understand what i mean..
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  17. #17
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: What's missing?

    in my code, everytime the change event of txtcode is triggered the txtsupply gets its value from my DB.
    but when you update txtcode change is not triggered, so you need to trigger it or reload the textboxes

    pete

  18. #18

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's missing?

    i think it will be triggered as because if I double click my listview the textboxes (including txtcode) will be filled up by the records found in my listview and since it is filled up the change event is triggered. Correct me for my analysis if Im wrong.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  19. #19
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: What's missing?

    check it cos if it was working right you wouldn't have this problem

    put a breakpoint in the txtcode change event to see if it is triggered

    pete

  20. #20

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's missing?

    I tried it thrice and yes it is being triggered. I have this code in dblclick event of the listview
    VB Code:
    1. sSQL = "UPDATE tblStocks SET Quantity = Quantity + " & txtQty.Text & " WHERE [Code]= '" & (lstStocks.ListItems.Item(edwin).Text) & "'"
    2.     oConn.Execute sSQL
    3.      
    4.     Debug.Print sSQL
    5.     Debug.Print rsStocks.Fields("quantity")
    this is what is shown in my immediate window
    UPDATE tblStocks SET Quantity = Quantity + 5 WHERE [Code]= '4806020497341'
    75

    at first the txtsupply shows 80 i put 5 in txtqty then i press the enter key so that makes the quantity in my DB =75. I double click now my listview and the records will display in my txtsupply should be 80 not 75 because the code above added back 5 to 75 but its not displaying the correct value.
    Last edited by Simply Me; Jul 28th, 2006 at 08:20 PM.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  21. #21

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's missing?

    any idea here please?
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  22. #22
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: What's missing?

    Quote Originally Posted by Simply Me
    I tried it thrice and yes it is being triggered.
    Put a breakpoint on the If txtCode.Text <> "" Then line. Once it triggers, follow it with F8 and see if txtSupply gets updated and, if it does, to what value. If it doesn't you'll see why.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  23. #23

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: What's missing?

    thanks for all the reply! i got it working and thanks to erick widya for the solution.
    And for those who would like to know the solution, I am again posting it here. Just update the DB first before displaying anything in the textbox. Relocating the SQL query will do the trick.
    [Highlight=VB]Private Sub lstStocks_DblClick()
    If lstStocks.ListItems.Count = 0 Then
    Exit Sub
    Else
    edwin = lstStocks.SelectedItem.Index
    sSQL = "UPDATE tblStocks SET Quantity = Quantity + " & lstStocks.ListItems.Item(edwin).SubItems(2) & " WHERE [Code]= '" & (lstStocks.ListItems.Item(edwin).Text) & "'"
    oConn.Execute sSQL

    txtCode.Text = lstStocks.ListItems.Item(edwin).Text
    txtDiscount.Text = Val(lstStocks.ListItems.Item(edwin).SubItems(4)) '/ Val(lstStocks.ListItems.Item(edwin).SubItems(2))
    txtQty.Text = lstStocks.ListItems.Item(edwin).SubItems(2)
    txtSellingPrice.Text = Val(lstStocks.ListItems.Item(edwin).SubItems(3))
    lstStocks.ListItems.Remove (edwin)
    txtCode.Locked = True

    cAmountDueTemp = 0
    For i = 1 To lstStocks.ListItems.Count
    cAmountDueTemp = CCur(cAmountDueTemp) + CCur(lstStocks.ListItems.Item(i).SubItems(5))
    txtAmountDue.Text = cAmountDueTemp
    Next
    lstStocks.Enabled = False
    End If
    End Sub
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width