Run time sorting on tabular form by cliciking labels

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sam12
    New Member
    • Apr 2008
    • 16

    Run time sorting on tabular form by cliciking labels

    HI there
    i have this kind of employee list form in my database

    select flag first name lastname dob
    x xxxxx xxxxxx xxxxxxxx
    x xxxxx xxxxxx xxxxxxxx
    x xxxxx xxxxxx xxxxxxxx
    x xxxxx xxxxxx xxxxxxxx

    i wnat to do sorting of records on a tabular form by clicking on the header label of each field like first name or last name.This form is based on a query which is sorted by lastname.do i need to make different quries for each sorting.I think i can do it by orderby feature but i don'n know how to implement this in coding.
    Thanks in advance
  • wassimdaccache
    New Member
    • Apr 2007
    • 222

    #2
    use this code
    Code:
        1.
          Private Sub btnSortAsc_Click()
       2.
              'sets focus to previously active control as the current is [btnSortAsc]
       3.
              Application.Screen.PreviousControl.SetFocus
       4.
              'perform ascending sort command
       5.
              DoCmd.RunCommand acCmdSortAscending  ' or acCmdSortDescending
       6.
          End Sub


    on the labeb properties got to onclick event and insert this code.

    NB: you have to get focus on the field to sort .E
    WASSIM S DACCACHe

    Comment

    • sam12
      New Member
      • Apr 2008
      • 16

      #3
      Thanks wassim for ur reply
      this code helped me to do sorting

      Me.OrderBy = "Control_Na me" 'or = "tablename.fiel dname"
      Me.OrderByOn = True

      Comment

      Working...