|
-
Sep 17th, 2000, 09:03 PM
#1
I'm still not having any luck.
I'm grabbing text from four texboxes and adding it to a list view with four columns with the click of a button. What is the Syntax for checking if the data I'm about to add to the listview already exists? Here's my current code that adds data to my columns.
Private Sub cmdAddToListView_Click()
Set sitem = lstCustomers.ListItems.Add(, , txtFields(1).Text)
sItem.SubItems(1) = txtFields(2).Text
sItem.SubItems(2) = txtFields(3).Text
sItem.SubItems(3) = txtFields(4).Text
End Sub
-
Sep 17th, 2000, 11:09 PM
#2
Hyperactive Member
Code:
Private Sub cmdAddToListView_Click()
On Error Resume Next
Set sitem = lstCustomers.ListItems.Add(, , txtFields(1).Text)
If Err.Number = 0 Then
sItem.SubItems(1) = txtFields(2).Text
sItem.SubItems(2) = txtFields(3).Text
sItem.SubItems(3) = txtFields(4).Text
Else
MsgBox "Already Exists"
End If
End Sub
-
Sep 17th, 2000, 11:40 PM
#3
Hello,
I did get this to work, so give it a try.
Code:
Private Sub cmdAddToListView_Click()
Dim sItem As ListItem
Dim itmFound As ListItem
Set itmFound = lstCustomers.FindItem(txtFields(0).Text, lvwText, , lvwPartial)
If itmFound Is Nothing Then
Set sItem = lstCustomers.ListItems.Add(, , txtFields(0).Text)
sItem.SubItems(1) = txtFields(1).Text
sItem.SubItems(2) = txtFields(2).Text
sItem.SubItems(3) = txtFields(3).Text
Else
MsgBox "Item already listed"
End If
End Sub
Hope this helps,
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
|