Filliing MSFlexgrid

in the following code I want to fill MSFlexGrid1 by the recordset (RS) data but it gives me error.

Private Sub Form_Load()
RS.Close
RS.open "Select * from Table1"
Me.MSHFlexGrid1.DataSource = RS
End Sub

Feel free to suggest and ammend this code to fill MSFlexGrid1 by the recordset data using SQL statements.

Note: I have already defined and opened the RS and ADODB connection in another lines in my project.

Thanx

LVL 1
asnsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

supunrCommented:
Private Sub Form_Load()
RS.Close
RS.open "Select * from Table1"
Set Me.MSHFlexGrid1.DataSource = RS
End Sub
0
sazhagianambiCommented:
Hi,

Tryout This,

RS.open "Select * from Table1"
'MSHFlexGrid1.clear
Set MSHFlexGrid1.Recordset = RS

Regards,
Nambi




0
tsravankCommented:
   rs.Open "<Query>", cn2, adOpenStatic
    rs.MoveLast
    rs.MoveFirst
        detgrid.Rows = rs.RecordCount + 1
        detgrid.Cols = rs.Fields.Count
        For i = 1 To rs.RecordCount
            For j = 0 To rs.Fields.Count - 1
                detgrid.TextMatrix(i, j) = rs.Fields(j).Value
            Next j
            rs.MoveNext
        Next
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

rinkujainCommented:
You can solve your purpose by following way :

Private Sub Form_Load()
MSHFlexGrid1.rows=2
i=1
While RS.EOF <> True
       MSHFlexGrid1.TextMatrix(i, 0) = i
       msfxopt.TextMatrix(i, 1) = RS.Fields(0)
       MSHFlexGrid1.TextMatrix(i, 2) = RS.Fields(1)
       ------------------
       -----------
       RS.movenext
        i = i + 1
        msfxopt.Rows = msfxopt.Rows + 1
       ''if you want only 16 rows display at a time in your grid then give following code

        If MSHFlexGrid1.Rows < 16 Then
          MSHFlexGrid1.Height = MSHFlexGrid1.Height + MSHFlexGrid1.CellHeight
        End If
       MSHFlexGrid1.Rows = MSHFlexGrid1.Rows - 1
Wend
end sub
Hope this may help you
0
toni2002Commented:
this will do it

Private Sub Form_Load()
RS.Close
RS.open "Select * from Table1"
Set Me.MSHFlexGrid1.DataSource = RS
End Sub

use MSHFlexGrid for ADO
use MSFlexGrid for DAO
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
go2abdulCommented:
where is the followup for ur question? the above suggesstion working with u or not.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.