Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Filliing MSFlexgrid

Posted on 2003-03-31
6
Medium Priority
?
380 Views
Last Modified: 2012-08-13
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

0
Comment
Question by:asns
6 Comments
 
LVL 11

Expert Comment

by:supunr
ID: 8242153
Private Sub Form_Load()
RS.Close
RS.open "Select * from Table1"
Set Me.MSHFlexGrid1.DataSource = RS
End Sub
0
 
LVL 1

Expert Comment

by:sazhagianambi
ID: 8243066
Hi,

Tryout This,

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

Regards,
Nambi




0
 

Expert Comment

by:tsravank
ID: 8243439
   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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:rinkujain
ID: 8243703
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
 

Accepted Solution

by:
toni2002 earned 300 total points
ID: 8244006
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
 

Expert Comment

by:go2abdul
ID: 8244284
where is the followup for ur question? the above suggesstion working with u or not.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, 19 hours left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question