please help me..
i have 40 data to display at msflexgrid. but i cannot do that because it show too many continuations error...

Public Function show_msflex(SQL As String)

MSFlexGrid1.Rows = 1

Set rekod = New ADODB.Recordset

    rekod.ActiveConnection = Con
    rekod.CursorLocation = adUseClient
    rekod.CursorType = adOpenDynamic
    rekod.LockType = adLockOptimistic
    rekod.Source = SQL
    rekod.Open
    If rekod.EOF Then
        MsgBox "Sorry, no record in the database"
    End If

While Not rekod.EOF()
    MSFlexGrid1.AddItem rekod!Name & vbTab & _
    rekod!Gender & vbTab & _
    rekod!Race & vbTab & _
    rekod!Address & vbTab & _
    rekod!Address1 & vbTab & _
    rekod!Ic & vbTab & _
    rekod!passport & vbTab & _
    rekod!DOB & vbTab & _
    rekod!POB & vbTab & _
    rekod!Post & vbTab & _
    rekod!State & vbTab & _
    rekod!Contact & vbTab & _
    rekod!coursecode & vbTab & _
    rekod!Citizen & vbTab & _
    rekod!Class & vbTab & _
    rekod!Sem & vbTab & _
    rekod!Admission & vbTab & _
    rekod!AdmissionDate & vbTab & _
    rekod!Completion & vbTab & _
    rekod!Roll & vbTab & _
    rekod!Intake & vbTab & _
    rekod!How & vbTab & _
    rekod!Sponsor & vbTab & _
    rekod!status & vbTab & _
    rekod!GState
    rekod.MoveNext
Wend

Set rekod = Nothing
End Function

Hi, Instead of specifying the field name use field index and a loop.
For Example

Dim sAdd as String 
Dim i as Integer 
For i = 0 To rekod.Fields.Count - 1
   sAdd = rekod.Fields(i) & vbTab
Next

MSFlexGrid1.AddItem sAdd

But it cannot be in order unless you specify the Fields order in SQL.

thanks for the reply. i try your code. but msflexgrid didnt show any data.

Hi,

Check this :

Dim i As Integer
  Dim j As Integer
  i = 0
  Do While  Not rekod.EOF
     i= i +1
     With MSFlexGrid1
          .Rows = i+1
           For j = 0 To rekod.Fields.Count-1
              .TextMatrix(i , j) =rekod(j) & ""             
           Next
      End With
     rekod.MoveNext
  Loop

Regards
Veena

Yes, Veena gives the correct code.
I give another way that use Recordset.GetRows. It may be faster.

Dim i    As Long
   Dim j    As Long
   Dim sC   As Variant
   Dim iU1  As Long
   Dim iU2  As Long
   Dim sS   As String
   
   MSFlexGrid1.Clear
   MSFlexGrid1.Cols = adoRS.Fields.Count
   MSFlexGrid1.Rows = adoRS.RecordCount + 1
      
   sC = adoRS.GetRows

   iU1 = UBound(sC, 1)
   iU2 = UBound(sC, 2) 'No of Records
   For j = 0 To iU1
      MSFlexGrid1.TextMatrix(0, j) = adoRS.Fields(j).Name
   Next
   
   For i = 0 To iU2
      For j = 0 To iU1
         MSFlexGrid1.TextMatrix(i + 1, j) = sC(j, i) & ""
      Next
   Next

i tried your code mr selvaganapathy, but i got an error. "operation is not allowed when the object is closed"

Hi,

Selva asuumes that your Recordset object name is "adoRS" and it it is opened.. if it is not, then change the variable name to your variable name of the recordset

Regards
Veena

thanks for all coz helping me so much
i have solved my prob
;)

This question has already been answered. Start a new discussion instead.