by R Bhaskara Ramaya C K (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 11th April 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This function is used to fill the Ms Flex grid dynamically.Just copy this code and place in your modules.Call that function in your VBForm.
API Declarations
Option Compare Text
Public Function FillGrid(pGrid As MSFlexGrid, Sql As String) As Boolean
Dim llngCount1 As Long
Dim llngCount2 As Long
Dim rs As New ADODB.Recordset
On Error GoTo ErrHndFillGrid
rs.Open Sql, conlocal, adOpenKeyset, adLockReadOnly
If rs.RecordCount <> 0 Then
rs.MoveLast
rs.MoveFirst
pGrid.Cols = rs.Fields.Count + 1
For llngCount1 = 0 To rs.Fields.Count - 1
pGrid.Row = 0
pGrid.Col = llngCount1 + 1
pGrid.Text = rs.Fields(llngCount1).Name
Next llngCount1
pGrid.Rows = rs.RecordCount + 1
For llngCount1 = 0 To rs.RecordCount - 1
pGrid.Row = llngCount1 + 1
pGrid.Col = 0
pGrid.Text = llngCount1 + 1
For llngCount2 = 0 To rs.Fields.Count - 1
pGrid.Col = llngCount2 + 1
If rs(llngCount2).Type = adDate Then
pGrid.Text = Format(rs(llngCount2), "dd-mmm-yyyy")
Else
pGrid.Text = Trim(rs(llngCount2)) & ""
End If
Next llngCount2
rs.MoveNext
Next llngCount1
FillGrid = True
Else
FillGrid = False
End If
rs.Close
Set rs = Nothing
Exit Function
ErrHndFillGrid:
FillGrid = False
End Function
No comments have been posted about This function is used to fill the Ms Flex grid dynamically.Just copy this code and place in your mo. Why not be the first to post a comment about This function is used to fill the Ms Flex grid dynamically.Just copy this code and place in your mo.