Results 1 to 5 of 5
  1. #1
    tylerg11 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    200

    Button to Sort by Field


    I'd like to add a button to my form that, when clicked, sorts the records in ascending order based on a certain field. Does anyone have any code that I would use to accomplish this? Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Options include setting the OrderBy and OrderByOn properties, or setting the RecordSource property to an SQL statement with the appropriate sorting.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    tylerg11 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    200
    Would that by the OrderBy Property of the button? I heard that I could use something like this in the VBA Editor:

    Code:
    FieldName.OrderBy

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No, those are all properties of the form. You should see examples in VBA help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    What does your form look like? If you are using continuous view, you can click the down arrow on the header of the field to sort...

    How does your original form sort?

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

Similar Threads

  1. Multivalue field sort order
    By bdaun in forum Forms
    Replies: 0
    Last Post: 09-05-2011, 12:27 PM
  2. adding a sort control button
    By darklite in forum Forms
    Replies: 5
    Last Post: 01-24-2011, 03:32 PM
  3. Sort according to field length?
    By wawinc in forum Queries
    Replies: 4
    Last Post: 12-15-2010, 04:27 PM
  4. a-z sort for control button
    By darklite in forum Access
    Replies: 7
    Last Post: 05-28-2010, 04:49 AM
  5. Macro Button to Sort Field A-Z
    By rdirosato in forum Access
    Replies: 1
    Last Post: 03-11-2010, 10:32 PM

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