CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2001
    Posts
    9

    msflexgrid datasource

    Hi All.
    Im trying to bind an ADO 2.5 recordset to a sp4 ms flexgrid, and it keeps telling the object variable is not set for the flex grid. Any ideas?
    TIA




  2. #2
    Join Date
    Dec 2000
    Posts
    12

    Re: msflexgrid datasource

    Hi TIA,

    have you got any further information?
    Maybe some of your code?

    A. Kempf


  3. #3
    Join Date
    Mar 2001
    Posts
    9

    Re: msflexgrid datasource

    pretty straight forward.
    Maybe I need to set some properties beforehand?


    'This gets my recordset from datalayer
    set rs = Data.GetClarkGrd(m_strConnect)


    'This line bombs
    set grdClark.DataSource = rs

    'I tried this before the last one and I get
    'the same object required error
    set grdClark.DataSource = nothing





    TIA(thanx in Advance)



  4. #4
    Join Date
    Dec 2000
    Posts
    12

    Re: msflexgrid datasource

    Shouldn't it be:

    set grdClark.DataSource = rs.DataSource



    instead of

    set grdClark.DataSource = rs






  5. #5
    Join Date
    Mar 2001
    Posts
    9

    Re: msflexgrid datasource

    It may be rs.Datasource,
    but when I try to set anything to it,
    even nothing, vb tells me that the object
    variable is not set.
    I tried set grd.datasource = rs.datasource
    and I got the same error, do I need to set
    any properties on the flex grid, or anything of
    the sort?
    Thanx again for your help.




  6. #6
    Join Date
    Aug 2001
    Location
    North Bend, WA
    Posts
    1,947
    I'm having the same problem. Did you ever get a reply?

  7. #7
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    Same here, I'm currently working on it, and at the moment the solution I'm using is:

    Code:
    For j = 1 To rs.RecordCount
        For i = 1 To rs.Fields.Count
            flxDetail.Rows = rs.RecordCount
            flxDetail.Cols = rs.Fields.Count
            flxDetail.Row = j
            flxDetail.Col = i
        
            flxDetail.AddItem (rs.GetString(adClipString, 1, (chr13)))
            If rs.Fields("display_title") = 1 Then
                flxDetail.CellFontBold = True
            End If
        Next i
        rs.MoveNext
    Next j
    But as I said, I'm still working on it.

  8. #8
    Join Date
    Jan 2002
    Posts
    195
    Your problem is pretty simple.

    1. Add a data control to the form.(Data1)
    2. set the databaseName Property of Data1 to your database
    3. Set the DataSource of your Grid to Data1
    4. Now you can set the RecordSource of Data1 either by selecting a table in the properties box or programatically using a select statment...ie.

    Data1.RecordSource = "select [Field1],[Field2],... from [Table] where [Fieldx]=" & Data1.Recordset![Fieldx]& "'" & " Order by [Fieldx]"

    "select [Field1],[Field2],... from [Table]"

    This allows you to place only the feilds,from the table, that you want in the grid.

    Is required everything else is optional.

    where [Fieldx]=" & Data1.Recordset![Fieldx]

    selects only the the Records that meet the Feildx = Data1.Recordset Fieldx condition. this can also read >,<,ect.

    "'" & " Order by [Fiildx]"
    Places the items in the grid in order according to Fieldx

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

Featured