The line itm.ListSubItems.Item(j).Bold = chkBold.Value is giving me error out of bound i think is bcoz of the size of j variable which is related to remark option.. but dont knw how to remove the error
Private Sub AddBoldItems()
Dim i, j As Integer
Dim itm, origItem As ListItem
lvBold.ListItems.Clear
lvBold.ColumnHeaders.Add 1, , "TermID", 1500
lvBold.ColumnHeaders.Add 2, , "TermName", 2000
lvBold.ColumnHeaders.Add 3, , "Remark", 3500
For i = 1 To lvTerms.ListItems.Count
If lvTerms.ListItems(i).Checked = True Then
If lvTerms.ListItems(i).ListSubItems.Count > 0 Then
For j = 1 To lvTerms.ListItems(i).ListSubItems.Count
Set origItem = lvTerms.ListItems(i)
Set itm = lvBold.ListItems.Add(, , origItem.Text)
itm.SubItems(1) = origItem.SubItems(1)
itm.Bold = True
itm.Bold = chkBold.Value
itm.ListSubItems.Item(j).Bold = chkBold.Value
lvBold.Refresh
Next
End If
End If
Next i
End Sub
8 3188 QVeen72 1,445
Recognized Expert Top Contributor
Hi,
All ListView/ListBox/Combos have Items Index from 0 to Count-1
Change your Code this way:
For i = 0 To lvTerms.ListItems.Count -1
.
.
For j = 0 To lvTerms.ListItems(i).ListSubItems.Count -1
Regards
Veena
Hi...
I did the changes but getting the same error
what other changes i can do to make it work?
Hi,
All ListView/ListBox/Combos have Items Index from 0 to Count-1
Change your Code this way:
For i = 0 To lvTerms.ListItems.Count -1
.
.
For j = 0 To lvTerms.ListItems(i).ListSubItems.Count -1
Regards
Veena
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
Change it to :
itm.ListSubItems.Item(1).Bold = chkBold.Value
Regards
Veena
Ok if i do this changes the problem is the remark bark is not adding to the lvBold... coz tht is Item(j) only... and this way my first TermId repeiting 2 times..
the main problem is with tht remark part of my Lvterms which i want to add to the lvbold and not adding... do u have any other solution?
thankx in advance
Hi,
Change it to :
itm.ListSubItems.Item(1).Bold = chkBold.Value
Regards
Veena
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
With your logic, itm always has only one subItem. your code doesnot show adding other 2 subitem..
Either add remaining 2 SubItems and use J , or use only 1..
Regards
Veena
oK... Thanks alot for ur help... i have changed my code to this and i m getting all the part but in this line itm.SubItems(3) = origItem.SubItems(3) is telling me "invalid property value" .... wht else i can do?
Private Sub AddBoldItems()
Dim i, j As Integer
Dim itm, origItem As ListItem
lvBold.ListItems.Clear
lvBold.ColumnHeaders.Add 1, , "TermID", 1500
lvBold.ColumnHeaders.Add 2, , "TermName", 2000
lvBold.ColumnHeaders.Add 3, , "Remark", 3500
For i = 1 To lvTerms.ListItems.Count
If lvTerms.ListItems(i).Checked = True Then
If lvTerms.ListItems(i).ListSubItems.Count > 0 Then
For j = 1 To lvTerms.ListItems(i).ListSubItems.Count
Set origItem = lvTerms.ListItems(i)
Set itm = lvBold.ListItems.Add(, , origItem.Text)
itm.SubItems(1) = origItem.SubItems(1)
itm.SubItems(2) = origItem.SubItems(2)
itm.SubItems(3) = origItem.SubItems(3)
itm.Bold = True
itm.Bold = chkBold.Value
itm.ListSubItems.Item(3).Bold = chkBold.Value
lvBold.Refresh
Next
End If
End If
Next i
End Sub
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
Try this code: -
-
Private Sub AddBoldItems()
-
Dim i, j As Integer
-
Dim itm, origItem As ListItem
-
lvBold.ListItems.Clear
-
lvBold.ColumnHeaders.Add 1, , "TermID", 1500
-
lvBold.ColumnHeaders.Add 2, , "TermName", 2000
-
lvBold.ColumnHeaders.Add 3, , "Remark", 3500
-
For i = 1 To lvTerms.ListItems.Count
-
If lvTerms.ListItems(i).Checked = True Then
-
If lvTerms.ListItems(i).ListSubItems.Count > 0 Then
-
Set origItem = lvTerms.ListItems(i)
-
Set itm = lvBold.ListItems.Add(, , origItem.Text)
-
For j = 1 To lvTerms.ListItems(i).ListSubItems.Count -1
-
itm.SubItems(j) = origItem.SubItems(j)
-
itm.Bold = chkBold.Value
-
Next
-
itm.ListSubItems.Item(3).Bold = chkBold.Value
-
lvBold.Refresh
-
End If
-
End If
-
Next i
-
End Sub
Regards
Veena
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kevin Little |
last post by:
#!/usr/bin/env python
'''
I want to dynamically add or replace bound methods in a class. I want
the modifications to be immediately effective across all instances,
whether created before or...
|
by: CSDunn |
last post by:
Hello,
I have an MS Access 2003 Project form in which I need to set the value
of a textbox named 'TestGrade' to the value present after the update
of a combo box currently named 'Combo6'. The data...
|
by: James Fortune |
last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't
understand why people who know how to write code to completely replace
a front end do not write something that will automate...
|
by: Abhi |
last post by:
FYI:
This message is for the benefit of MS Access Community. I found that
this prblem has been encounterd by many but there is hardly any place
where a complete solution is posted. So I thought...
|
by: Igor Shevchenko |
last post by:
Hi.
I've got a problem with using cursor in a plpgsql function. Cursor is created
via DECLARE, it's SELECT query has placeholders. I use PostgreSQL 7.4.2.
Here's a problematic plpgsql...
| |
by: Furty |
last post by:
Hi,
I'm looking for the best practice for creating a generic data validation
implementation for my data bound business objects. I currently have a
business object base class implementing the...
|
by: gmccallum |
last post by:
I have a data entry screen using controls bound through a bindingSource,
TableAdaptor and a BindingNavigator to move through the records.
When I have an data entry error (such as Null for a value)...
|
by: Bishop |
last post by:
Any ideas on why this is happening or how I can fix it?
For instance if I forget to declare a SQL Variable and assign it a value
instead of telling me that it redirects to 404 page not found...
|
by: mknoll217 |
last post by:
I am recieving this error from my code:
The multi-part identifier "PAR.UniqueID" could not be bound.
The multi-part identifier "Salary.UniqueID" could not be bound.
The multi-part identifier...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |