Click to See Complete Forum and Search --> : msflexgrid datasource


sumit_karan
March 27th, 2001, 08:02 AM
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

Alexander Kempf
March 27th, 2001, 08:30 AM
Hi TIA,

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

A. Kempf

sumit_karan
March 27th, 2001, 08:49 AM
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)

Alexander Kempf
March 27th, 2001, 09:36 AM
Shouldn't it be:

set grdClark.DataSource = rs.DataSource



instead of

set grdClark.DataSource = rs

sumit_karan
March 27th, 2001, 10:02 AM
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.

billwilson3
October 16th, 2002, 07:19 PM
I'm having the same problem. Did you ever get a reply?

Twodogs
October 16th, 2002, 10:03 PM
Same here, I'm currently working on it, and at the moment the solution I'm using is:


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.

Erik Wiggins
October 17th, 2002, 05:17 AM
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