[RESOLVED] MSFlexgrid Refresh (?) or Redraw (?)
Hi,
I have an MSFlexgrid grid displayed initially sorted by student ID. In the display, I have a sort command button for LastName sorting. The problem is i can't refresh the display after clicking the sort button.
Thanking you in advance.
Here's my code:
VB Code:
-----------------------------------------------------------
Private Sub cmdSort_Click()
varSortBy = "LastName" ' varSortBy is global var
Call Form_Load
End Sub
-----------------------------------------------------------
Private Sub Form_Load()
If varSortBy = "" Then
'Initial Form Load
varSortBy = "s_id"
MSFlexGrid2.FormatString = "Test"
Data2.DatabaseName = App.Path & "\Student.mdb"
Data2.RecordSource = "Select * FROM Projects ORDER BY " & varSortBy
Else
'Called from sort button
varSortBy = varSortBy
MSFlexGrid2.FormatString = "Test"
Data2.DatabaseName = App.Path & "\Student.mdb"
Data2.RecordSource = "select * FROM Projects ORDER BY " & varSortBy
MSFlexGrid2.Refresh
End If
End Sub
Re: MSFlexgrid Refresh (?) or Redraw (?)
Bound controls are evil, and hard to use. I always load the flexgrid myself. If I requery, I just clear the grid and call the reload method again. It may be a little bit slower, but I have full control over the formatting, color, and alignment of each cell in the grid.
Re: MSFlexgrid Refresh (?) or Redraw (?)
Call the Refresh method of the Data Control not the FlexGrid or use the Sort method of the FlexGrid and avoid a requery.
Re: MSFlexgrid Refresh (?) or Redraw (?)
There are particular peculiarities of the MSHFlexGrid in terms of changing the underlying recordsource in any way. I wittered on about them a bit in this thread. Basically, using Set MSHFlexGrid.Recordset = ... seems the way to go.
Re: MSFlexgrid Refresh (?) or Redraw (?)
Thanks a lot BruceVde. It's working now.
Quote:
Originally Posted by brucevde
Call the Refresh method of the Data Control not the FlexGrid or use the Sort method of the FlexGrid and avoid a requery.