Results 1 to 2 of 2
  1. #1
    domivaxaccess is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    1

    Macro event depending sorting ASC or DESC

    Good Morning,

    I have a Continuous form with the following fields: ‘Surname’, ‘Givenname’ & ‘City’.

    With the right button of the mouse, from the contextual menu, I can sort the column in ascending or descending.

    How to do on the event of my form under ‘On Apply Filter’ to execute a macro depending if the fields is sorting in ascending or descending.

    I tried the below but does not work.



    Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
    If Me.Surname Like "DESC" = True Then
    Macro1
    ElseIf Me.Surname Like "ASC" = True Then
    Macro2
    ElseIf Me.Givenname’ Like "DESC" = True Then
    Macro3
    ElseIf Me.Givenname’ Like "ASC" = True Then
    Macro4
    Etc…
    End If
    End Sub



    Thank you for you help.
    Best Regards,
    Xavier

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    My preference is to adjust the Form's RecordSource via an SQL string.

    THis seems to work though. Just be careful about setting focus in fields that allow edits.

    Me.NameOfControl.SetFocus
    Application.RunCommand acCmdSortAscending

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Asc/Desc/reset sort button code
    By mightyteegar in forum Programming
    Replies: 2
    Last Post: 10-30-2012, 04:24 PM
  2. Replies: 6
    Last Post: 10-11-2012, 02:19 PM
  3. Replies: 2
    Last Post: 10-05-2012, 07:52 AM
  4. Replies: 11
    Last Post: 01-12-2012, 07:55 PM
  5. ORDER BY error when using DESC in an IIf
    By Smitoris in forum Queries
    Replies: 2
    Last Post: 10-30-2011, 02:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums