Results 1 to 8 of 8
  1. #1
    josnow is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    10

    Creating asending order

    I want to sort the fields in my form so that the list box shows the information alphabetically. I have a form with Role and TeamMember which I want to have ascending. I have the following information:



    Me.OrderBy = “[Role] ASC”
    Me.OrderByOne = True

    I’ve tried putting this code in several spot on the Role field properties of my form. What am I doing wrong?

  2. #2
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    The sort order in a list box is independant of the sort order of the form itself. Your Me.OrderBy = “[Role] ASC” will sort the form, but not the list box. To see the list box alphabetically, you need an "order by" somewhere in the row source for the listbox itself. If the source is a query, you could put the sort in the query.

    John

  3. #3
    josnow is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    10
    Hi John,

    I have my form based on tables not on a query. Would I go under the property sheet for this list box and add code into that? If so, what would I add?

    Joyce


    Quote Originally Posted by John_G View Post
    Hi -

    The sort order in a list box is independant of the sort order of the form itself. Your Me.OrderBy = “[Role] ASC” will sort the form, but not the list box. To see the list box alphabetically, you need an "order by" somewhere in the row source for the listbox itself. If the source is a query, you could put the sort in the query.

    John

  4. #4
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    You have me confused here - which is it you are having problems sequencing? As I understand it, you have a form, and on the form is a list box. The form is based on a table - but what is the source of the data shown in the list box? Is it the list box you want to have sorted alphabetically, the form records, or both?

    Can you clarify this, please?

    Thanks

    John

  5. #5
    Mirslr is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    3
    if you are doing in SQL then
    here is the easy example
    SELECT * FROM name
    ORDER BY LastName ASC

    I see your mistake is that you should try to put ASC outside of parthesis

  6. #6
    josnow is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    10
    Hi John,

    It is the list box that I want sorted alphabetically.

    Joyce

  7. #7
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi:

    It's an easy solution, then - just use SQL as the row source for the list box, with an order by as required, e.g.

    Select LastName, FirstName from MemberTable order by LastName

    replacing the field and table names with the ones you are using.

    John

  8. #8
    josnow is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    10
    Hi John, your query will not work since I need to build the query only in access forms. I'm using 4 tables to build this form. I don't know how to see this in SQL since I only can see the tables themselves. Is there a way in forms to get back into SQL so that I can do the order by?

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

Similar Threads

  1. Creating a Purchase Order
    By bnecrush in forum Access
    Replies: 12
    Last Post: 11-20-2012, 06:27 PM
  2. Creating Job/order summary report
    By lpkorn423 in forum Reports
    Replies: 0
    Last Post: 07-25-2012, 05:53 AM
  3. Replies: 2
    Last Post: 06-18-2012, 03:33 PM
  4. How to order columns in ascending order?
    By darkingthereturn in forum Access
    Replies: 5
    Last Post: 06-18-2012, 05:24 AM
  5. Id Order
    By Rockin-John in forum Forms
    Replies: 15
    Last Post: 05-03-2011, 02:39 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