We help IT Professionals succeed at work.

# Recordset into Listview

on
1,103 Views
Experts:

I have a piece of code (See below) that I am having some difficulty with. I want the list view to grab the Product Name (pdtname) from the rst instead of the Product Number (pdtnumber) in the
first column of the list view. Right now the first column is the pdtnumber......so for the matching pdtnumber in the array populate the matching pdtname from the recordset. Any ideas?

Thanks.

Code Snippet:

conn.Open

' Create the number of columns you need.

For j = 1 To 32

k = VBGetProdData(j, stnpd(j))

' filter out blanks here
If stnpd(j).pdtno > 0 Then

Set oItem = lvwData.ListItems.Add(, , stnpd(j).pdtno)

With lvwData.ListItems(j)

.SubItems(1) = stnpd(j).issord
.SubItems(2) = stnpd(j).pdtdmy

End With

j1 = j1 + 1

End If

Next j
Comment
Watch Question

## View Solution Only

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)

Commented:
not really what i needed, but a good post non the less. I appreciate your response so I accepted the answer. Thank you. The solution I wanted is below...I used the rst.Filter to solve the issue.

thanks again.

CODE SNIPPET:

For j = 1 To 32

k = VBGetProdData(j, stnpd(j))

' filter out blanks here
If stnpd(j).pdtno > 0 Then

rst.Filter = "pdtno = '" & stnpd(j).pdtno & "'"
Set oItem = lvwData.ListItems.Add(, , rst!PublicationDate)

With lvwData.ListItems(j)

rst.Filter = "pdtno = '" & stnpd(j).pdtno & "'"
.SubItems(1) = rst!ProductName
.SubItems(2) = stnpd(j).pdtno
.SubItems(3) = stnpd(j).publyear
.SubItems(4) = stnpd(j).issord
.SubItems(5) = stnpd(j).pdtrnno

End With

j1 = j1 + 1

End If

Next j
Unlock the solution to this question.

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.