Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009

    Red face Unanswered: PLz Plz! I need Help with MS FlexGrid in VB 6.0.

    Hello Everyone,

    I am actually new to VB 6.0 programming. In a small project I am trying to show the entire records of a table,located in Oracle database, in a hierarchichal flexgrid.
    But when I set the dataSource property of FlexGrid to the Recordset object, I get "Run Time Error 91, Object Variable or With Block Variable not Set."
    following is the code in the Load event of the form containing the FlexGrid.

    Private Sub Form_Load()
    Dim adoConn As New ADODB.Connection
    Dim ConnectionString As String
    adoConn.CursorLocation = adUseClient
    ConnectionString = "Provider=MSDAORA; user id= scott; password= tiger;"
    adoConn.Open ConnectionString
    Dim adoRecSet As New ADODB.Recordset
    adoRecSet.CursorType = adOpenDynamic
    adoRecSet.LockType = adLockOptimistic
    adoRecSet.Open "employee1", adoConn, , , adCmdTable
    Set MSFlexGrid1.DataSource = adoRecSet
    End Sub

    Any help will be Highly Appreciated..

    Thanks a Ton in advance.

  2. #2
    Join Date
    Jan 2003
    British Columbia
    It looks like you are using the FlexGrid not the Hierarchical FlexGrid.

    The FlexGrid cannot be bound directly to an ADO Recordset, it must be bound to an ADO Data Control.

    The alternative is to populate the grid using code.

        adoRecSet.Open "employee1", adoConn, , , adCmdTable
        With MSFlexGrid1
            .Rows = .FixedRows
            .Cols = adoRecSet.Fields.Count + .FixedCols
            Do Until adoRecSet.EOF
                .AddItem String$(.FixedCols, vbTab) & adoRecSet.GetString(, 1, , " ")
        End With
    End Sub

  3. #3
    Join Date
    Sep 2009

    Thank you

    Thank you very much.

    You are right. I was required to use MS hierarchichal FlexGrid. And mistakenly i used MS FlexGrid.
    I changed the thing and it worked smoothly.

    Thanks a Ton.

Posting Permissions

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