Results 1 to 5 of 5
  1. #1
    The Professor is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Location
    Cambridgeshire, UK
    Posts
    67

    Sort Order for Records in Subforms

    Hi,



    I have a One to Many relational database, based on two Tables (Customers and Invoices). One Customer Record can be linked to many Invoice Records.

    The Invoices Table is displayed in a Subform on the Customer Form. As you browse through the Customer Records, the Invoice Records for the relevant customer are displayed in the Subform - this part works very well. Obviously, the Subform displays only one Invoice Record at a time, but as each customer can have several or more invoices, my issue is this - how do I determine in what order the Invoice Records are displayed in the Subform?

    For example, if a customer has 20 invoices, (only the first of which will be displayed in the Subform) how do I force them to be displayed in a particular order as I cycle through them? I'd like them to be displayed in date order (using the Date field) showing the latest Invoice Record first. But equally they could be sorted by the Invoice Number field, starting with either the lowest or highest number first - if only I knew how it could be done. Currently they appear to be just random in their sort order. The Invoices Table behind the Subform is sorted by the Invoice Number field, but this isn't reflected in the order in which they are being displayed in the Subform.

    There doesn't seem to be a Property for the Subform Control that I can set, that will determine in what order the Records for the Subform will be sorted. I'd really appreciate some help with this if anyone has some ideas.

    Prof.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Sort order is managed by the subform container SourceObject. Is the SourceObject a table, query, or form? They all have an Order By property. Otherwise, use a query or form with a query as RecordSource and apply sort criteria within the query.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    You should be able to use the Order By property, but I'd base the subform on a query that included the sorting you wanted. You know the subform can display multiple invoices if you want?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    The Professor is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Location
    Cambridgeshire, UK
    Posts
    67
    Hi June7,

    The SourceObject is a Table. I have now found the OrderBy property, but there no 'dropdown list' nor 'expression builder' for that property, so what do I put in there? A field? If so, (say a date field) how do I tell it (in the OrderBy property) to sort hi - lo, or A - Z etc?

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    1)As Paul said you could use a query on the table with an Order By.

    2)To use the table, try

    Order By ="YourieldName Desc" .... the DESC is descending, omit it if you want ascend which is default.
    Last edited by orange; 06-29-2013 at 10:23 AM.

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

Similar Threads

  1. Sort order with null values
    By Alsail77 in forum Access
    Replies: 23
    Last Post: 08-27-2012, 05:04 PM
  2. Sort order in a sub form
    By roar58 in forum Forms
    Replies: 1
    Last Post: 03-17-2012, 08:57 PM
  3. Sort order by Dlookup field
    By 1Giggles in forum Forms
    Replies: 1
    Last Post: 02-22-2012, 02:13 PM
  4. Report will order/sort 4 columns but not 5. Why?
    By TomHolden in forum Reports
    Replies: 6
    Last Post: 12-17-2011, 04:25 PM
  5. Multivalue field sort order
    By bdaun in forum Forms
    Replies: 0
    Last Post: 09-05-2011, 12:27 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