Results 1 to 5 of 5

Thread: [RESOLVED] MSFlexgrid Refresh (?) or Redraw (?)

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    45

    Resolved [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:
    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

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    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.

  4. #4
    Hyperactive Member
    Join Date
    May 2005
    Posts
    324

    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.

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    45

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width