Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Column Properties 1

Status
Not open for further replies.

RonRepp

Technical User
Feb 25, 2005
1,031
US
Hi all:

I posted this in thread707-1576484, but sense I'll get an answer here.

I'd like to add the schema columns to a listview control.



Here's what I have:

Code:
Private Sub TV1_Click()

Select Case TV1.SelectedItem.Key
    
    
    
    Case "TABLE"
        LV1.ListItems.Clear
        LV1.ColumnHeaders.Clear
        Exit Sub
    Case "Root"
        LV1.ListItems.Clear
        LV1.ColumnHeaders.Clear
        Exit Sub
    Case "VIEW"
        LV1.ListItems.Clear
        LV1.ColumnHeaders.Clear
        Exit Sub
    Case Else
        
        LV1.ColumnHeaders.Clear
        LV1.ColumnHeaders.Add , , "Field"

        Dim Con As ADODB.Connection
        Dim FieldsRS As ADODB.Recordset
        Dim S As String
        Dim Pos As Integer
    
        Dim LI As ListItem
        LV1.View = lvwReport
        
        
        Set Con = New ADODB.Connection
        Con.ConnectionString = sCon
        Con.Open sCon
    
        Set FieldsRS = Con.OpenSchema(adSchemaColumns)
        
        LV1.ListItems.Clear
        
    While Not FieldsRS.EOF
        If FieldsRS.Fields(2) = TV1.SelectedItem.Text Then
            LV1.ListItems.Add , , FieldsRS(3)
            Debug.Print "First"
            Debug.Print FieldsRS(7)
            Debug.Print "2nd"
            Debug.Print FieldsRS(6)
        End If
        FieldsRS.MoveNext
    Wend
    Set FieldsRS = Nothing
    
End Select

Con.Close
Set Con = Nothing


End Sub

I'm finding the field names easy enough, but I'd also like to find the Type (INT,Text...), the length, and other properties.

Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
How are ya RonRepp . . .

Have a look here to get the Idea thread705-1480808

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
AceMan:

Awesome! I had to finigle it a bit to fit my needs, but you hit it right on the head.

Now, are there other properties that I could get using the same function? I'm filling a listview with FIELD_Name, FIELD_TYPE,...is there anything else useful to the user?

Thanks again,


Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top