Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2003
    Location
    Columbia, MO
    Posts
    57

    Unanswered: Simple Form Order By

    Hello.

    I have a simple question that I can't seem to find out how to do correctly. I have a subform that I want sorted by BirthDate in ascending order. In the form's properties, how do I state that in the Order By section? I have tried just putting the field name in there and a few variations, but it still won't work. If anybody has any thoughts on this subject, I would greatly appreciate it.

    Thanks,

    David

  2. #2
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    Add order by command

    You can use order by function

    Order by [tbl].[field];

    example: ORDER BY [Projects].[ProjectName];

    You can add this command at the end of your statment. Like select statement or sql statement or qry statement.

    let me know if that helps...

  3. #3
    Join Date
    Jan 2003
    Location
    Columbia, MO
    Posts
    57
    Thanks for the reply.

    I tried entering that in the Order By Property on the form, but it didn't do anything.

    The form is based on a table. Maybe I should write a query and base the form off of it instead of the table and sort it there. I'm not sure.

  4. #4
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    OK, try this...

    1. open the form in design mode
    2. Click on View > Properties
    3. Click on the "DATA" Tab
    4. You should see "Order by"
    5. Put your sql statement in Order by area

  5. #5
    Join Date
    Jan 2003
    Location
    Columbia, MO
    Posts
    57
    I entered this there:

    ORDER BY [dbo_CalfData].[CalfBDate];

    It still doesn't work. I wonder if my pop up calendar on this field in the form has anything to do with it?

  6. #6
    Join Date
    Dec 2002
    Location
    Houston, Texas
    Posts
    74

    more info...

    You can use the OrderBy property to specify how you want to sort records in a form, query, report, or table.

    Setting

    The OrderBy property is a string expression that is the name of the field or fields on which you want to sort records. When you use more than one field name, separate the names with a comma (,).
    When you set the OrderBy property by entering one or more field names, the records are sorted in ascending order. Similarly, Visual Basic sorts these fields in ascending order by default.
    If you want to sort records in descending order, type DESC at the end of the string expression. For example, to sort customer records in descending order by contact name, set the OrderBy property to "ContactName DESC".

    You can set the OrderBy property by using the object's property sheet, a macro, or Visual Basic.

    Remarks

    For reports, the OrderByOn property must be set to Yes to apply the sort order specified by the object's OrderBy property. For forms, select the field by which you want to sort the records and either click the appropriate Sort button on the toolbar, or point to Sort on the Records menu and click the appropriate command on the submenu. You can also set the OrderByOn property for either forms or reports by using Visual Basic.

    Setting the OrderBy property for an open report will run the report's Close and Open event procedures.

    Note When a new object is created, it inherits the RecordSource, Filter, OrderBy, and OrderByOn properties of the table or query it was created from. For forms and reports, inherited filters aren't automatically applied when an object is opened.

  7. #7
    Join Date
    Jan 2003
    Location
    Columbia, MO
    Posts
    57
    That will work just fine.

    I appreciate your help. I had been struggling with this fow a little while.

    Thanks,

    David

Posting Permissions

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