Try this joe
Code:
Dim vFldsArray() As Variant 'Array to hold the recordset
Dim CN As ADODB.Connection
Dim rS As ADODB.Recordset
Private Sub Form_Load()
Dim sSQL As String
Dim iCols As Integer
Dim iRows As Integer
Dim iNoOfRecords As Integer
Dim iNoOfFields As Integer
Set CN = New ADODB.Connection
'change the datasource
CN.ConnectionString = "provider=microsoft.jet.oledb.4.0;" _
& "data source=" & App.Path & "\db1.mdb"
CN.Open
Erase vFldsArray
Set rS = New ADODB.Recordset
sSQL = "SELECT * FROM MyTable" 'change the table
rS.Open sSQL, CN, adOpenKeyset, adLockOptimistic, adCmdText
vFldsArray = rS.GetRows
rS.Close
iNoOfFields = UBound(vFldsArray, 1) + 1
iNoOfRecords = UBound(vFldsArray, 2) + 1
With Me.MSFlexGrid1
.Cols = iNoOfFields + .FixedCols
.Rows = iNoOfRecords + .FixedRows
For iRows = 1 To .Rows - 1
For iCols = 1 To .Cols - 1
'Populating the Grid
.TextMatrix(iRows, iCols) = vFldsArray(iCols - 1, iRows - 1)
Next iCols
Next iRows
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
If rS.State = adStateOpen Then rS.Close
Set rS = Nothing 'Releasng the rS memory
If CN.State = adStateOpen Then CN.Close
Set CN = Nothing 'Releasing the connection memory
Erase vFldsArray 'Releasing the Array
End Sub
Happy programming