Results 1 to 12 of 12
  1. #1
    wsurritte is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Nixa, MO
    Posts
    6

    Sorting by combobox problem

    I'm having a little sorting problem that I would really appreciate some help with: I have a datasheet form on tbl_clocks, with a combo box on the field location_id. That combo box will display the actual location from qry_vision_company_location; no real problem there. The problem that I'm having is I want to sort the datasheet by the location name, and if I do the sort in the record source query, it sorts by the ID instead of by the name. The only way I've found around this is to click "ascending" once the form is already open, but that is not a good solution.




    I would really appreciate any suggestions on resolving this.

    Thanks,
    William

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you using Lookup Fields per chance? http://www.mvps.org/access/lookupfields.htm

  3. #3
    wsurritte is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Nixa, MO
    Posts
    6
    No, I'm storing the ID in the table, and just setting a Row Source property on a combobox in the form. i discovered once using PHP that Access stores a string when you use the lookup wizard, and thus the performance is terrible, so I quit using the lookup wizard.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If you join the two takes in the RecordSource query then you can sort on any field in either table without actually displaying the field.

  5. #5
    wsurritte is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Nixa, MO
    Posts
    6
    @RG: I just tried your suggestion; it still is ordering them by location_id even though I listed the name field as ascending.

    I'm not telling it anywhere to order by that id; I haven't the slightest clue why it's doing this.


    Thanks,
    William

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    When you open the Query directly in design view and go to Datasheet view, does it sort correctly? Are you using a static or dynamic query for the RecordSource of the form?

  7. #7
    wsurritte is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Nixa, MO
    Posts
    6
    No; the query is sorted by the ID there too. Forgive my ignorance, but I don't know the difference between a static query and a dynamic query; if you are meaning a named query under the query's section on the left, then no - the query is just the record source of the form.

    Thanks,
    William

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Save the query as a named query. Then you can play with it better and YES, an SQL statement as the RecordSource of a form is a Dynamic Query and not quite as efficient as one that has been saved under its own name which is then static. Does the query show sorting on the ID value?

  9. #9
    wsurritte is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Nixa, MO
    Posts
    6
    RG,

    After saving it as a static query, `location_id` was sorted asc, so I joined it to the other table, and created the sort field, and now I can sort by location name. If I want to "sub-sort" by say `serial_number`, I would simply need to set it to Ascending also right? I was thinking that access would sort by the order you select the fields to sort.

    Thanks so much,
    William

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The SubSort order is the left to right order of the fields in Design view of the query.

  11. #11
    wsurritte is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Nixa, MO
    Posts
    6
    RG,

    Thanks so much for your assistance, I really appreciate it. My access database is now cooperating

    Best,
    William

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! Glad we could help.

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

Similar Threads

  1. Replies: 10
    Last Post: 12-21-2010, 12:41 PM
  2. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  3. report formating/sorting problem
    By bill4364 in forum Reports
    Replies: 1
    Last Post: 02-19-2010, 08:15 PM
  4. Combobox problem
    By newitsupport in forum Access
    Replies: 1
    Last Post: 09-26-2009, 01:03 PM
  5. Is this a Query or Sorting problem?
    By bwrobel in forum Queries
    Replies: 2
    Last Post: 07-14-2006, 08:15 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