-
February 27th, 2013, 07:53 AM
#1
ListView Problem without saving in DB Acces Using VB 6.0
Hello Guys.. I have a Code For Saving Item in ListView But My Problem is What If My First Column Same BarCode into Example:
Barcode QTY
001 5
And I add Another Item
Barcode QTY
001 5
001 5
My Point is What Should I do And How to Do The Quantity of two Itme Added in One Then They BEcome
Barcode QTY
001 10
This is My Code for Adding in Listview
Code:
ListView1.ListItems.Add , , lblrp.Caption
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtCode.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtproductname.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtqty.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtprice.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , lbltotal.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , MDIForm1.lbldate.Caption
Help me Guys
Thanks in Advance
-
February 27th, 2013, 12:25 PM
#2
Re: ListView Problem without saving in DB Acces Using VB 6.0
You should probably check to see if the item is already in the list before you add it and if it is in the list update the qty of the one that is already there rather than adding another one.
Always use [code][/code] tags when posting code.
-
February 27th, 2013, 05:57 PM
#3
Re: ListView Problem without saving in DB Acces Using VB 6.0
In My Mind What if Customer Buy 3 Items of My Clothes then I forget to Enter the Qty into 3 , then I want ti enter Again the Barcode to Added the Another One, Then The Value of the One Item is Automatically Updated If There is Already Item in list..
-
February 27th, 2013, 06:38 PM
#4
Re: ListView Problem without saving in DB Acces Using VB 6.0
this is my Code..
What Should I Do? Doesnt Work
Code:
If txtCode.Text = ListView1.SelectedItem.ListSubItems.Add Then
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtCode.Text
Else
ListView1.ListItems.Add , , lblrp.Caption
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtCode.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtProductName.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtQty.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtPrice.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , lbltotal.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , MDIForm1.lbldate.Caption
End If
-
February 27th, 2013, 06:58 PM
#5
Re: ListView Problem without saving in DB Acces Using VB 6.0
To check if the code is already in the listview you should iterate all the listview's rows
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
-
February 27th, 2013, 07:08 PM
#6
Re: ListView Problem without saving in DB Acces Using VB 6.0
Originally Posted by jggtz
To check if the code is already in the listview you should iterate all the listview's rows
How To iterate all the listview's rows What Should I do?
-
February 27th, 2013, 08:02 PM
#7
Re: ListView Problem without saving in DB Acces Using VB 6.0
You would use a loop and check each item. If you find the item then update the qty on that subitem and exit the loop
If no match was found then and only then would you use the .additem method to add a new item to the list.
Always use [code][/code] tags when posting code.
-
February 27th, 2013, 08:09 PM
#8
Re: ListView Problem without saving in DB Acces Using VB 6.0
Originally Posted by DataMiser
You would use a loop and check each item. If you find the item then update the qty on that subitem and exit the loop
If no match was found then and only then would you use the .additem method to add a new item to the list.
Sir It possible use the loop in listview? I am Saving Item in ListView Without Saving in DB,..
I Actually know to use loop if my item automatically Save in Db, But in My Problem, no I dont know how to loop the item in Listview because The Item was save in Listview not Saving in Db ..
Sir Any Idea how to loop the item in listview?
Thanks Sir..
-
February 27th, 2013, 08:49 PM
#9
Re: ListView Problem without saving in DB Acces Using VB 6.0
Hello Sir.. I am Using FindItem to Find item in listview but i dont how to Add the Qty of the same item in one..
Code:
Dim itm As MSComctlLib.ListItem
Set itm = ListView1.FindItem(txtCode.Text, lvwSubItem)
'for partial search use this:
'''Set itm = ListView1.FindItem("partial text goes here", lvwSubItem, , lvwPartial)
If Not itm Is Nothing Then
itm.EnsureVisible
itm.Selected = True
MsgBox "Found"
Else
ListView1.ListItems.Add , , lblrp.Caption
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtCode.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtproductname.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtqty.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtprice.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , lbltotal.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , MDIForm1.lbldate.Caption
End If
-
February 27th, 2013, 09:11 PM
#10
Re: ListView Problem without saving in DB Acces Using VB 6.0
Originally Posted by jggtz
To check if the code is already in the listview you should iterate all the listview's rows
sir thanks for the idea..
this is my code and run perfectly i am happy so much thank
Code:
Dim qtyadd As String
Dim subtotaladd As String
Dim itm As MSComctlLib.ListItem
Dim i As Integer
Set itm = ListView1.FindItem(txtCode.Text, lvwSubItem)
If Not itm Is Nothing Then
itm.EnsureVisible
itm.Selected = True
MsgBox "Found"
qtyadd = Val(txtqty.Text) + Val(ListView1.SelectedItem.SubItems(3))
subtotaladd = Val(lbltotal.Text) + Val(ListView1.SelectedItem.SubItems(5))
ListView1.SelectedItem.SubItems(3) = qtyadd
ListView1.SelectedItem.SubItems(5) = Format(subtotaladd, "###################.00")
Else
ListView1.ListItems.Add , , lblrp.Caption
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtCode.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtproductname.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtqty.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , txtprice.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , lbltotal.Text
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , MDIForm1.lbldate.Caption
End If
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|