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:
  1. -----------------------------------------------------------
  2. Private Sub cmdSort_Click()
  3.     varSortBy = "LastName"                    ' varSortBy is global var
  4.     Call Form_Load
  5. End Sub
  6.  
  7. -----------------------------------------------------------
  8. Private Sub Form_Load()
  9.      
  10.     If varSortBy = "" Then
  11.      
  12.        'Initial Form Load
  13.  
  14.        varSortBy = "s_id"
  15.        MSFlexGrid2.FormatString = "Test"
  16.        Data2.DatabaseName = App.Path & "\Student.mdb"
  17.        Data2.RecordSource  = "Select * FROM Projects ORDER BY " & varSortBy
  18.    
  19.    Else
  20.    
  21.       'Called from sort button
  22.  
  23.        varSortBy = varSortBy
  24.        MSFlexGrid2.FormatString = "Test"
  25.        Data2.DatabaseName = App.Path & "\Student.mdb"
  26.        Data2.RecordSource = "select * FROM Projects ORDER BY " & varSortBy
  27.                                    
  28.        MSFlexGrid2.Refresh
  29.  
  30.      End If
  31.                        
  32. End Sub