Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004

    Unanswered: Sort Button Problem

    I have a form based on a query. The form displays records in a tabulated fashion (like excel). I wish to place a toggle button on top of each column that would allow me to sort de records in an ascending or descending order for each individual column. Any help would be greatly appreciated. Thanks!

  2. #2
    Join Date
    Oct 2003
    you can use hte menu option for form filter. You can easily use them in your code.

  3. #3
    Join Date
    Nov 2003
    Here is a simple way do do what you want. Here we use the MouseDown event for whichever control that may be used to issue the sort order (you could also use the KeyDown event). The reason for this is because we have easy access to the shift button state. In other words, if a command button is used to initiate the sort order then under normal circumstances the sort order will be set as Ascending (default) when the mouse button is clicked onto the control. But, if the Shift key is held in the down position while the control is clicked then the sort order is set to Descending. This prevents the need to place a seperate control for the want of either a Ascending or Descending order.

    Private Sub myControlsName_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    	Application.Echo False 'Turn Echo off to Prevent flicker
    	If Shift = 1 Then 'Is the Shift Key pressed (1 = yes : 0 = No)
    	 'Descending Order
    	 Me.OrderBy = "[myTableFieldName] DESC" 'The table item to base the sort from.
    	 'Ascending Order
    	 Me.OrderBy = "[myTableFieldName]" 'The table item to base the sort from.
    	End If
    	Me.OrderByOn = True 'Turn ON the Sort
    	Me.Requery 'Requery the Form
    	Application.Echo True 'Turn Echo back on
    End Sub

    Hope this helps a little.......

  4. #4
    Join Date
    Jun 2004
    Thank you all for your help, just got back and could not reply. I wil give your suggestions a shot!

Posting Permissions

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