Results 1 to 4 of 4

Thread: MSHFlexGrid

  1. #1

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    46

    MSHFlexGrid

    Hi,

    I have a MSHFlexGrid that I want to populate with two RecordSets, how would I go about doing this? As if I do:

    Set MSHFlexGrid.DataSource = RS1
    Set MSHFlexGrid.DataSource = RS2

    This only shows the Data in RS2.

    Thanks,

    TrUz

  2. #2
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: MSHFlexGrid

    Take a look at this example and just append the second RS to the data in the FlexGrid. Remember like Hack always says "Why Bound Controls are Evil!!"
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  3. #3
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Arrow Re: MSHFlexGrid

    VB Code:
    1. Private Sub Command1_Click()
    2. R1.Open TSQL, Con, adOpenDynamic, adLockBatchOptimistic
    3. R2.Open TSQL, Con, adOpenDynamic, adLockBatchOptimistic
    4. Grid.AddItem R1!e_no & vbTab & R1!Name & vbTab & R1!Class & vbTab & R2!batch & vbTab & R2!Form & vbTab & R2!tution & vbTab & R2!hostal & vbTab & R1!refund & vbTab & R1!bus & vbTab & R1!bag & vbTab & R2!books & vbTab & R1!other
    5. End Sub

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: MSHFlexGrid

    To quickly append recordsets to a FlexGrid I use this method (it should be easy enough to adapt it for the Hierarchical Flex Grid). Note: Don't use this method if you need to format the data when populating the grid.

    VB Code:
    1. 'in a module
    2. Public Sub AppendToFlexGrid(FlexGrid As MSFlexGrid, Data As ADODB.Recordset)
    3.     Dim lngStartRow As Long
    4.    
    5.     With FlexGrid
    6.         lngStartRow = .Rows
    7.         .Rows = .Rows + Data.RecordCount
    8.         .Row = lngStartRow
    9.         .Col = .FixedCols
    10.         .ColSel = .Cols - 1
    11.         .RowSel = .Rows - 1
    12.         .Clip = Data.GetString
    13.     End With
    14.  
    15. End Sub
    16.  
    17. 'how to use example
    18. Private Sub Command1_Click()
    19.     Dim cn As ADODB.Connection
    20.     Dim rs As ADODB.Recordset
    21.    
    22.     With MSFlexGrid1
    23.         .Rows = .FixedRows
    24.         .Cols = 3
    25.     End With
    26.    
    27.     Set cn = New ADODB.Connection
    28.     cn.Open "provider=sqloledb;data source=handel;initial catalog=northwind;integrated security=sspi"
    29.    
    30.     Set rs = New ADODB.Recordset
    31.     rs.CursorLocation = adUseClient
    32.    
    33.     rs.Open "Select CustomerId, CompanyName From Customers", cn, adOpenStatic, adLockReadOnly, adCmdText
    34.     AppendToFlexGrid Me.MSFlexGrid1, rs
    35.    
    36.     rs.Close
    37.    
    38.     rs.Open "Select ShipperId, CompanyName From Shippers", cn, adOpenStatic, adLockReadOnly, adCmdText
    39.     AppendToFlexGrid Me.MSFlexGrid1, rs
    40.    
    41. End Sub

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