Results 1 to 2 of 2

Thread: Using the MSHFlexGrid

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Question

    How I use the MsHFlexGrid in an only recordset ? I want put the data hieraquily, putting the data with header the columns

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308
    Not sure what you want.
    You can use data control. Or you can fill through the code:
    Code:
    Private Sub Form_Load()
    
    'set FixedCols=0
    'set fixedRows=1
    'looks better
    Dim db As Database
    Dim rs As Recordset
    Dim strSQL As String
    Dim i As Integer
    Dim intRow As Integer
    Dim intCol As Integer
    
    Set db = OpenDatabase("Nwind.mdb")
    strSQL = "select CustomerID,CompanyName,Address from customers order by CompanyName desc "
    Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
    If rs.EOF And rs.BOF Then Exit Sub
    rs.MoveLast
    
    MSFlexGrid1.Rows = rs.RecordCount + 1
    MSFlexGrid1.Cols = rs.Fields.Count
    rs.MoveFirst
    intRow = 1
    
    Do Until rs.EOF
     For i = 0 To rs.Fields.Count - 1
                             
                    MSFlexGrid1.TextMatrix(0, i) = rs.Fields(i).Name
            
                    MSFlexGrid1.TextMatrix(intRow, i) = LTrim(rs.Fields(i).Value) & "" 'or Format(rs.Fields(i).Value) if rs has Null value
                    
        Next
        
        rs.MoveNext
        intRow = intRow + 1
        
    Loop

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width