-
Nov 18th, 2017, 02:09 AM
#1
Thread Starter
Enjoy the moment
[RESOLVED] searching in text to display data with checkbox resets over and over again why?
hey,
i have a listview with checkboxes that the user can choose.
i want to search in the text box and choose some data by clicking in the checkboxes
however
when i start the search and find the item,i click in the checkbox
and when i clear the textbox search the checkbox is unchecked.
how can i make a search and checkbox what ever i want and make
a new search but without clearing the checkbox i choosed before.
this is my code
Code:
Dim Rs As New ADODB.Recordset
Rs.Open "Select * From Inventory " & _
" Where InvSupplier = '" & StrSuppliernameSearch & "'" & _
" And InvItem LIKE '%" & RplS(TxtProductName.Text) & "%'" & _
" Order By InvItem", CN
LTreat.ListItems.clear
Do While Not Rs.EOF
Set itm = LTreat.ListItems.Add(, , Rs!InvItem)
itm.SubItems(1) = FormatCurrency(Rs!InvBeforeTax)
itm.SubItems(2) = FormatCurrency(Rs!InvForCust)
itm.SubItems(3) = Rs!InvQuantity
itm.SubItems(4) = FormatCurrency(Rs!InvPayments)
itm.SubItems(5) = Rs!InvParts
itm.SubItems(6) = Rs!Mahlakaid
Rs.MoveNext
Loop
Rs.Close
tnx for any help
salsa
-
Nov 18th, 2017, 08:25 AM
#2
Re: searching in text to display data with checkbox resets over and over again why?
Salsa
Your needs are a little unclear to me
Could you post at screenshot showing an example situation?
Spoo
-
Nov 18th, 2017, 08:27 AM
#3
Re: searching in text to display data with checkbox resets over and over again why?
Checkboxes are cleared each time you remove listitems. LTreat.ListItems.Clear
-
Nov 18th, 2017, 08:57 AM
#4
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
Originally Posted by LaVolpe
Checkboxes are cleared each time you remove listitems. LTreat.ListItems.Clear
i know sir.
is there a way to search the listview
check and checkbox and search again without clearing the selected one?
-
Nov 18th, 2017, 08:59 AM
#5
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
Originally Posted by Spooman
Salsa
Your needs are a little unclear to me
Could you post at screenshot showing an example situation?
Spoo
hey spoo
example
lets say i have 100 items in the list ok?
instead of searching one by onei want to search by name and check the item .
then i want to search for another item and check it too
but without losing the first checkbox i picked.
-
Nov 18th, 2017, 09:02 AM
#6
Re: searching in text to display data with checkbox resets over and over again why?
You are using the same display listview also as the search mechanism, via its checkboxes? Really unclear. Maybe a screenshot of before and what is wanted after? The best answer may be to have a separate search form, instead of trying to use an ever-changing listivew as the search mechanism.
Does your database contain a key/unique field identifier?
-
Nov 18th, 2017, 09:08 AM
#7
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
Does your database contain a key/unique field identifier?
no sir
You are using the same display listview also as the search mechanism, via its checkboxes?
yes
i am loading items from the database to the listview
the listview has checkboxes yes
i added a textbox to search the list.
i have like 500 items and instead of scroling the list
i want to search the textbox to find the item.
and then clear the textbox and search again for a diffrent item.
so the first checkbox needs to be cheked and not cleared.
-
Nov 18th, 2017, 09:12 AM
#8
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
or maybe is there a way just to search the listview after its been loaded
from the database
?
-
Nov 18th, 2017, 10:37 AM
#9
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
i tried this but it removes all
Code:
Dim X As Integer
For X = LTreat.ListItems.Count To 1 Step -1
Set itm = LTreat.ListItems(X)
If LTreat.ListItems(X).Text <> TxtProductName.Text Then
LTreat.ListItems.Remove (X)
End If
Next
is there a way to use the wild card so that it will match the first word?
-
Nov 18th, 2017, 10:46 AM
#10
Re: searching in text to display data with checkbox resets over and over again why?
13aslas...you're doing it all backwards...
Your code says to delete an item from your listview if, when going from the bottom to the top, what you are searching for is NOT found. What you MAY need is to simply change the "<>" to "="
-
Nov 18th, 2017, 11:05 AM
#11
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
you're doing it all backwards
why?
Code:
If LTreat.ListItems(X).Text <> TxtProductName.Text Then
look again sami
is there a way to use the wild card so that it will match the first word?
-
Nov 18th, 2017, 11:17 AM
#12
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
this also dosnt work
Code:
Dim X As Integer
For X = LTreat.ListItems.Count To 1 Step -1
Set itm = LTreat.ListItems(X)
If LTreat.ListItems(X).Text Like TxtProductName.Text Then
LTreat.ListItems(X).Selected = True
Exit For
Else
LTreat.ListItems.Remove (X)
End If
Next
-
Nov 18th, 2017, 11:40 AM
#13
Re: searching in text to display data with checkbox resets over and over again why?
LTreat.ListItems(X).Text Like TxtProductName.Text
Use * as the wildcard in your textbox. The text box should start and end with the *
Example: "Hello World" Like "*or*"
Also note that this is case-sensitive. To prevent that...
Code:
LCase$(LTreat.ListItems(X).Text) Like LCase$(TxtProductName.Text)
Edited: Otherwise, just use InStr() and don't mess with wildcards
Code:
If InStr(1, LTreat.ListItems(X).Text, TxtProductName.Text, vbTextCompare) > 0 Then ' found
Last edited by LaVolpe; Nov 18th, 2017 at 11:59 AM.
-
Nov 18th, 2017, 11:57 AM
#14
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
still dosnt work sir
i am doing something wrong i know
-
Nov 18th, 2017, 11:59 AM
#15
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
is this code ok?
Code:
Dim X As Integer
For X = LTreat.ListItems.Count To 1 Step -1
Set itm = LTreat.ListItems(X)
If LCase$(LTreat.ListItems(X).Text) Like LCase$(TxtProductName.Text) Then
LTreat.ListItems(X).Selected = True
Exit For
Else
LTreat.ListItems.Remove (X)
End If
Next
where do i add the * (wild card)?
please help sir figure this out
-
Nov 18th, 2017, 12:02 PM
#16
Re: searching in text to display data with checkbox resets over and over again why?
See my updated comments in my last reply. Personally, I prefer InStr() instead of Like.
Regarding your problem, it never helps us when someone says "it doesn't work". We need to know exactly what you expected and what actually happened, otherwise, we are forced to make assumptions. Here is my assumption... Not all items were removed that should have been removed. Is that correct? If so, it is because when you found your first match, you exited the the loop. Any other items that didn't match still remain in the list. If that is the case, simply remove the "Exit For" line.
Edited: Regarding your question, "where do I add the wildcard". I answered that in my previous reply to you... before and after the text in your textbox. Dynamically, you could do this...
Code:
LCase$(LTreat.ListItems(X).Text) Like "*" & LCase$(TxtProductName.Text) & "*"
But I'd still recommend using InStr() instead and not dealing with wildcards and not forcing LCase/UCase.
Last edited by LaVolpe; Nov 18th, 2017 at 12:07 PM.
-
Nov 18th, 2017, 12:23 PM
#17
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
OK SIR
i did like you say but after i check the checkbox
and then clear the textbox search then the items that was in the listview before are gone!!
Code:
Private Sub TxtProductName_Change()
Dim X As Integer
For X = LTreat.ListItems.Count To 1 Step -1
Set itm = LTreat.ListItems(X)
If LCase$(LTreat.ListItems(X).Text) Like "*" & LCase$(TxtProductName.Text) & "*" Then
LTreat.ListItems(X).EnsureVisible
Else
LTreat.ListItems.Remove (X)
End If
Next
End Sub
if i reload the items again from the database then the checkbox that i picked will be unchecked get it?
-
Nov 18th, 2017, 12:26 PM
#18
Re: searching in text to display data with checkbox resets over and over again why?
When you clear the listview the checkboxes are also cleared. You will have to manually check them, in code by setting the listitem's Checked property to True, when you re-add the listview items.
-
Nov 18th, 2017, 12:29 PM
#19
Re: searching in text to display data with checkbox resets over and over again why?
Hi salsa,
I didn't go threw the complete thread, but here a sample to search threw subitem(1) of a listview
Code:
Private Sub Command2_Click()
Dim i As Long
With ListView1
.MultiSelect = True
.HideSelection = False
.FullRowSelect = True
For i = 1 To .ListItems.Count
'look for salsa
If InStr(1, .ListItems(i).SubItems(1), "salsa") > 0 Then
.ListItems(i).Selected = True
Else
.ListItems(i).Selected = False
End If
Next
End With
End Sub
regards
Chris
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Nov 18th, 2017, 12:32 PM
#20
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
Originally Posted by ChrisE
Hi salsa,
I didn't go threw the complete thread, but here a sample to search threw subitem(1) of a listview
Code:
Private Sub Command2_Click()
Dim i As Long
With ListView1
.MultiSelect = True
.HideSelection = False
.FullRowSelect = True
For i = 1 To .ListItems.Count
'look for salsa
If InStr(1, .ListItems(i).SubItems(1), "salsa") > 0 Then
.ListItems(i).Selected = True
Else
.ListItems(i).Selected = False
End If
Next
End With
End Sub
regards
Chris
hey chris
i dont use a command button i use this
Code:
Private Sub TxtProductName_Change()
-
Nov 18th, 2017, 12:36 PM
#21
Re: searching in text to display data with checkbox resets over and over again why?
@Chris. Simply setting .Selected to true does not mark the checkbox as checked.
-
Nov 18th, 2017, 12:37 PM
#22
Re: searching in text to display data with checkbox resets over and over again why?
well that's up to you where to put a search Function/Sub
regards
Chris
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Nov 18th, 2017, 12:38 PM
#23
Re: searching in text to display data with checkbox resets over and over again why?
Salsa, is this what you are after? Note that this routine should only be called for your filtered results. Notice the one line I added (blue below)
Code:
Dim Rs As New ADODB.Recordset
Rs.Open "Select * From Inventory " & _
" Where InvSupplier = '" & StrSuppliernameSearch & "'" & _
" And InvItem LIKE '%" & RplS(TxtProductName.Text) & "%'" & _
" Order By InvItem", CN
LTreat.ListItems.clear
Do While Not Rs.EOF
Set itm = LTreat.ListItems.Add(, , Rs!InvItem)
itm.SubItems(1) = FormatCurrency(Rs!InvBeforeTax)
itm.SubItems(2) = FormatCurrency(Rs!InvForCust)
itm.SubItems(3) = Rs!InvQuantity
itm.SubItems(4) = FormatCurrency(Rs!InvPayments)
itm.SubItems(5) = Rs!InvParts
itm.SubItems(6) = Rs!Mahlakaid
itm.Checked = True
Rs.MoveNext
Loop
Rs.Close
-
Nov 18th, 2017, 12:39 PM
#24
Re: searching in text to display data with checkbox resets over and over again why?
Originally Posted by LaVolpe
@Chris. Simply setting .Selected to true does not mark the checkbox as checked.
Hi,
see change in Blue
Code:
Private Sub Command2_Click()
Dim i As Long
With ListView1
.MultiSelect = True
.HideSelection = False
.FullRowSelect = True
For i = 1 To .ListItems.Count
If InStr(1, .ListItems(i).SubItems(1), "So") > 0 Then
.ListItems(i).Selected = True
.SelectedItem.Checked = True
Else
.ListItems(i).Selected = False
End If
Next
End With
End Sub
regards
Chris
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Nov 18th, 2017, 12:41 PM
#25
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
i am getting frustrated from my self..
this is the whole code.
just tell me how can i search the textbox for an item
check the checkbox that i want and then clear the search (without the checkbox being clear)
and then run another search in the textbox.
this is how i load the items from the database
Code:
Private Sub LoadAgainItems()
Dim Rs As New ADODB.Recordset
Rs.Open "SELECT Inventory.InvItem, Inventory.InvForCust," & _
" Sum(Inventory.InvRemain) AS SumOfInvRemain, Inventory.InvParts," & _
" Inventory.InvBeforeTax, Inventory.InvQuantity, Inventory.MahlakaID" & _
" From Inventory" & _
" Where Inventory.InvSupplier = '" & StrSuppliernameSearch & "'" & _
" GROUP BY Inventory.InvItem, Inventory.InvForCust," & _
" Inventory.InvParts, Inventory.InvBeforeTax," & _
" Inventory.InvQuantity, Inventory.MahlakaID", CN
LTreat.ListItems.clear
Do While Not Rs.EOF
Set itm = LTreat.ListItems.Add(, , Rs!InvItem)
itm.SubItems(1) = FormatCurrency(Rs!InvBeforeTax)
itm.SubItems(2) = FormatCurrency(Rs!InvForCust)
itm.SubItems(3) = Rs!InvQuantity
itm.SubItems(4) = FormatCurrency(itm.SubItems(1) * itm.SubItems(3))
itm.SubItems(5) = Rs!InvParts
itm.SubItems(6) = Rs!Mahlakaid
Rs.MoveNext
Loop
Rs.Close
End Sub
this is the search part
Code:
Private Sub TxtMozarName_Change()
Dim X As Integer
For X = LTreat.ListItems.Count To 1 Step -1
Set itm = LTreat.ListItems(X)
If LCase$(LTreat.ListItems(X).Text) Like "*" & LCase$(TxtProductName.Text) & "*" Then
LTreat.ListItems(X).EnsureVisible
LTreat.ListItems(X).Selected = True
Exit For
Else
LTreat.ListItems.Remove (X)
End If
Next
Call LoadAgainItems
End Sub
-
Nov 18th, 2017, 12:50 PM
#26
Re: searching in text to display data with checkbox resets over and over again why?
Hi salsa,
just use the code I gave you, change the Subitem(1) to the Subitem you want to search.
However I would change the Sql, add the Search criteria and show just the result. Or why do
you open everything and then perform the search ?
regards
Chris
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Nov 18th, 2017, 12:57 PM
#27
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
hey Chris
please see post #25
-
Nov 18th, 2017, 01:04 PM
#28
Re: searching in text to display data with checkbox resets over and over again why?
Hi,
I did see post#25 , and it doesn't make sense.
Think about what you are doing.
a) you are creating a Sql with a criteria
Code:
" Where Inventory.InvSupplier = '" & StrSuppliernameSearch & "'" &
b) and then you are searching for a Productname
Code:
If LCase$(LTreat.ListItems(X).Text) Like "*" & LCase$(TxtProductName.Text) & "*" Then
??? it makes no sense to me
or can you explain why you have to search like that?
regards
Chris
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Nov 18th, 2017, 01:07 PM
#29
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
this is my quote before
how can i search the textbox for an item
check the checkbox that i want and then clear the search (without the checkbox being clear)
and then run another search in the textbox.
this is how i load the items from the database
-
Nov 18th, 2017, 01:07 PM
#30
Re: searching in text to display data with checkbox resets over and over again why?
@Salsa, did you see post #23? If that doens't do it, then I admit that I am not understanding the question completely
-
Nov 18th, 2017, 01:14 PM
#31
Re: searching in text to display data with checkbox resets over and over again why?
Hi Salsa,
I just looked at LaVolpes Post#23, that will solve your problem.
If you can't see that your problem is solved, take a break and look at it tomorrow, that's what I do when I get stuck.
regards
Chris
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Nov 18th, 2017, 01:22 PM
#32
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
Originally Posted by LaVolpe
@Salsa, did you see post #23? If that doens't do it, then I admit that I am not understanding the question completely
yes sir i did didnt help me :\
please read this
Code:
how can i search the textbox for an item
check the checkbox that i want and then clear the search (without the checkbox being clear)
and then run another search in the textbox.
-
Nov 18th, 2017, 01:30 PM
#33
Re: searching in text to display data with checkbox resets over and over again why?
I'll take one last stab a this... This is what is wanted:
1. You check items in the listview and create some search criteria from those checked items (your TxtProductName control)
2. You then requery the database and on return you want:
-- the original checked items still cheked
-- any new items unchecked
If the above is true, this would be so much easier if your records contained a primary/unique key. Without that, you will need to temporarily cache enough information about the checked listview items to identify them again after the listview is repopulated. Then you would go back and find each one from your cache and re-check them
-
Nov 18th, 2017, 01:38 PM
#34
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
1. You check items in the listview and create some search criteria from those checked items (your TxtProductName control)
2. You then requery the database and on return you want:
-- the original checked items still cheked
-- any new items unchecked
that is correct sir!!!!!!!!!!
this would be so much easier if your records contained a primary/unique key.
i dont have a primary/unique key.
Without that, you will need to temporarily cache enough information about the checked listview items to identify them again after the listview is repopulated. Then you would go back and find each one from your cache and re-check them
how can i do that?
-
Nov 18th, 2017, 01:44 PM
#35
Re: searching in text to display data with checkbox resets over and over again why?
Originally Posted by salsa31
i dont have a primary/unique key.
Add one then. Make it AutoNumber. And make sure it is returned in your query. Then this becomes a lot easier:
1. When your listview is populated without any search criteria. Add the unique key to each list item's TAG property
2. Now when it comes time to requery for the search criteria, your code changes just a bit...
- the example below assumes your primary/unique key field's name is: RecordID
-First you DO NOT clear the list items. But do remove all the unchecked ones, then
Code:
Dim Rs As New ADODB.Recordset
Rs.Open "Select * From Inventory " & _
" Where InvSupplier = '" & StrSuppliernameSearch & "'" & _
" And InvItem LIKE '%" & RplS(TxtProductName.Text) & "%'" & _
" Order By InvItem", CN
' LTreat.ListItems.clear <<< DO NOT clear the listing
Do While Not Rs.EOF
If LTreat.FindItem(rs!RecordID, lvwTag) Is Nothing Then
Set itm = LTreat.ListItems.Add(, , Rs!InvItem)
itm.SubItems(1) = FormatCurrency(Rs!InvBeforeTax)
itm.SubItems(2) = FormatCurrency(Rs!InvForCust)
itm.SubItems(3) = Rs!InvQuantity
itm.SubItems(4) = FormatCurrency(Rs!InvPayments)
itm.SubItems(5) = Rs!InvParts
itm.SubItems(6) = Rs!Mahlakaid
itm.Tag = rs!RecordID
End If
Rs.MoveNext
Loop
Rs.Close
-
Nov 18th, 2017, 01:51 PM
#36
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
First you DO NOT clear the list items. But do remove all the unchecked ones, then
if i dont clear the listview then it will show double of everything
-
Nov 18th, 2017, 01:55 PM
#37
Re: searching in text to display data with checkbox resets over and over again why?
Originally Posted by salsa31
if i dont clear the listview then it will show double of everything
Not with the code I posted in my previous reply, if you add a primary key to your table. LTreat.FindItem(rs!RecordID, lvwTag) will only return "Nothing" if the record does not exist in your listview. This is because as each list item is added to the listview, you include the RecordID in its Tag property. Now you can see why I said it is much simpler with a primary key? We know which records are in the listview and skip re-adding them if it's already there.
-
Nov 18th, 2017, 02:06 PM
#38
Thread Starter
Enjoy the moment
Re: searching in text to display data with checkbox resets over and over again why?
I understand now sir
thank you very much for your time and help
thank you Chris.
-
Nov 18th, 2017, 02:15 PM
#39
Re: [RESOLVED] searching in text to display data with checkbox resets over and over a
One last thing and another tweak. I noticed your query is sorted with an Order By clause. The option I suggested won't result in a sorted list because all the checked items will be at the top and all the new items sorted below them. If that's what you want, then ok. If it's not then the following tweak can be made
Do clear your listitems, but before doing that cache the checked RecordIDs in a collection and then go back and re-check them afterwards. This would prevent needing to remove unchecked items since the list will be cleared
Code:
Dim colKeys As Collection, n As Long
Set colKeys = New Collection
For n = 1 To LTreat.ListItems.Count
If LTreat.ListItems(n).Checked = True Then
colKeys.Add LTreat.ListItems(n).Tag
End If
Next
Dim Rs As New ADODB.Recordset
Rs.Open "Select * From Inventory " & _
" Where InvSupplier = '" & StrSuppliernameSearch & "'" & _
" And InvItem LIKE '%" & RplS(TxtProductName.Text) & "%'" & _
" Order By InvItem", CN
LTreat.ListItems.clear
Do While Not Rs.EOF
Set itm = LTreat.ListItems.Add(, , Rs!InvItem)
itm.SubItems(1) = FormatCurrency(Rs!InvBeforeTax)
itm.SubItems(2) = FormatCurrency(Rs!InvForCust)
itm.SubItems(3) = Rs!InvQuantity
itm.SubItems(4) = FormatCurrency(Rs!InvPayments)
itm.SubItems(5) = Rs!InvParts
itm.SubItems(6) = Rs!Mahlakaid
itm.Tag = rs!RecordID
Rs.MoveNext
Loop
Rs.Close
For n = 1 To colKeys.Count
Set itm = LTreat.Find(colKeys(n), lvwTag)
If Not itm Is Nothing Then itm.Checked = True
Next
Set colKeys = Nothing
Edited: good idea but won't work for you I think. I think you want all the checked items to remain in the listview even on the 2nd and 3rd search, even if they no longer match the search criteria? Not really sure. If that's the case, then clearing the list will remove all checked items (as described), but if your new query doesn't return them, they are permanently removed. So, if this is the case and you still want your list sorted, use the logic that does not clear the list. Then sort using the listivew SortKey and Sorted properties instead of using an Order By clause. Sorry, still not 100% sure what you are looking for.
Last edited by LaVolpe; Nov 18th, 2017 at 02:35 PM.
-
Nov 18th, 2017, 03:02 PM
#40
Re: [RESOLVED] searching in text to display data with checkbox resets over and over a
Salsa
Use of CheckBoxes is new to me, but here is something I came up with
It doesn't match your situation directly, but it does deal with CheckBoxes
Controls
- Command1 (not shown)
- ListView1
- Text2
Concept
- ListView is prepopulated (you can adjust as needed)
- TextBox contains the total price of checked items
Code snippet to update Text2 as each CheckBox is checked.
Code:
Private Sub ListView1_Click()
'
Dim itmA As ListItem
tot = 0
With ListView1
For ii = 1 To .ListItems.count
Set itmA = .ListItems.Item(ii)
If itmA.Checked = True Then
vv = Val(itmA.SubItems(1))
tot = tot + vv
Text2.Text = tot
End If
Next ii
End With
'
End Sub
Here is screenshot
If a CheckBox is subsequently Unchecked, to revised total is displayed
I can post more code if you need.
HTH
EDIT-1
Wow .. a lot has transpired since I began composing this post about 2 hours ago.
I see you've now marked it as RESOLVED
Glad you guys worked it out.
Spoo
Last edited by Spooman; Nov 18th, 2017 at 03:07 PM.
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
|