Solved

List View and VISIBLE PROPERTY:

Posted on 2004-04-26
4
417 Views
Last Modified: 2013-12-25
Hi everyone:

I am bringing a table to the list view1, this table has 7 fields, one field is ID. So, I would like to diplay all 6 except ID. But, I want to bring ID, so that I can modify specific record if they click. So, how do I do that?
I tried:

    With ListView1
        .ColumnHeaders.Add(, , "Company").Tag = "Company"
        .ColumnHeaders.Add(, , "Contact").Tag = "Contact"
        .ColumnHeaders.Add(, , "City").Tag = "City"
        .ColumnHeaders.Add(, , "State").Tag = "State"
        .ColumnHeaders.Add(, , "Country").Tag = "Country"
        .ColumnHeaders.Add(, , "Phone").Tag = "Phone"
        .ColumnHeaders.Add(, , "ID").Tag = "ID"
        .ColumnHeaders(1).Alignment = lvwColumnLeft
        .ColumnHeaders(2).Alignment = lvwColumnLeft
        .ColumnHeaders(3).Alignment = lvwColumnLeft
        .ColumnHeaders(4).Alignment = lvwColumnLeft
        .ColumnHeaders(5).Alignment = lvwColumnLeft
        .ColumnHeaders(6).Alignment = lvwColumnLeft
        .ColumnHeaders(6).Alignment = lvwColumnLeft
        .ColumnHeaders(1).Width = .Width / 7
        .ColumnHeaders(2).Width = .Width / 7
        .ColumnHeaders(3).Width = .Width / 7
        .ColumnHeaders(4).Width = .Width / 7
        .ColumnHeaders(5).Width = .Width / 7
        .ColumnHeaders(6).Width = .Width / 7
        .ColumnHeaders(6).Width = .Width / 7

    End With

rs.Open "Select CompanyName, ContactName, City, State, Country, PhoneNumber, ID From TblClients  ORDER BY ID ", cn, adOpenKeyset, adLockOptimistic
    If rs.EOF = False Then
        While Not rs.EOF
            If rs.EOF = False Then
                With ListView1
                    With .ListItems
                        With .Add(, , IIf(IsNull(rs(0)) = False, rs(0), ""))
                            .ListSubItems.Add , , IIf(IsNull(rs(1)) = False, rs(1), "")
                            .ListSubItems.Add , , IIf(IsNull(rs(2)) = False, rs(2), "")
                            .ListSubItems.Add , , IIf(IsNull(rs(3)) = False, rs(3), "")
                            .ListSubItems.Add , , IIf(IsNull(rs(4)) = False, rs(4), "")
                            .ListSubItems.Add , , IIf(IsNull(rs(5)) = False, rs(5), "")
                            .ListSubItems.Add , , IIf(IsNull(rs(6)) = False, rs(6), "")
                        End With
                    End With
                End With
            rs.MoveNext
            Else
                rs.Close
                Exit Sub
            End If
        Wend
    Else
       
    End If
    rs.Close

So, I do not want to display ID field in the listview1 but, I do need this info.

Thank you all
0
Comment
Question by:neonlights
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
p_sie earned 500 total points
ID: 10922128
Put the ID in the Tag in the first column of the listview!

Dim Item as ListItem

rs.Open "Select CompanyName, ContactName, City, State, Country, PhoneNumber, ID From TblClients  ORDER BY ID ", cn, adOpenKeyset, adLockOptimistic
    If rs.EOF = False Then
        While Not rs.EOF
            If rs.EOF = False Then
                With ListView1
                    With .ListItems
                        Set item = .Add(, , IIf(IsNull(rs(0)) = False, rs(0), ""))

                        With   Item                    
                            .Tag = rs(ÏD")         'Put the ID in the Tag of the first column
                            .ListSubItems.Add , , IIf(IsNull(rs(1)) = False, rs(1), "")
                            .ListSubItems.Add , , IIf(IsNull(rs(2)) = False, rs(2), "")
                            .ListSubItems.Add , , IIf(IsNull(rs(3)) = False, rs(3), "")
                            .ListSubItems.Add , , IIf(IsNull(rs(4)) = False, rs(4), "")
                            .ListSubItems.Add , , IIf(IsNull(rs(5)) = False, rs(5), "")
                            .ListSubItems.Add , , IIf(IsNull(rs(6)) = False, rs(6), "")
                        End With
                    End With
                End With
            rs.MoveNext
            Else
                rs.Close
                Exit Sub
            End If
        Wend
    Else
       
    End If
    rs.Close


To get the ID of the selected row:

ID = listview.selectedItem.Tag
0
 

Author Comment

by:neonlights
ID: 10924660
Thanks  very much P_Sie.

0
 
LVL 9

Expert Comment

by:p_sie
ID: 10925725
Your welcome!
0
 
LVL 1

Expert Comment

by:daniellyh
ID: 11194055
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question