Results 1 to 6 of 6
  1. #1
    bo_dong is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    3

    Access ADP Form Sort on ComboBox Text

    Here is BenchmarkCategory table. Notice the BenchmarkCategoryName is not sorted alphabetically when sorted by BenchmarkCategoryID.



    [See Picture 1]

    Here is another table Benchmark with a BenchmarkCategoryID column. I built a form on the table and added a ComboBox displaying the BenchmarkCategoryName. Because users would like to see Names instead of IDs.

    [See Picture 2]

    My question is how to sort the ComboBox column based on the names, not on IDs? So it looks like the below picture, not the above picture?

    [See Picture 3]

    I did the above picture by changing the RecordSource on the Benchmark table to

    select * from Benchmark c order by (select p.BenchmarkCategoryName from BenchmarkCategory p where p.BenchmarkCategoryID = c.BenchmarkCategoryID) desc

    But this hack doesn't work in SubForms. Using Profiler, I saw ADP sending broken queries to SQL Server.

  2. #2
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    You can write a query or view for the recordsource of the combobox....then put your desired sort in the query.

  3. #3
    bo_dong is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    3
    I don't want to sort the values in the ComboBox. I want to sort the Main Form based on the text values in the ComboBox.

  4. #4
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    You need to change the query of your form to include the tables that are bound to the combobox....using the appropriate join.

  5. #5
    bo_dong is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    3
    My question then is how to make picture 2 look like picture 3 without changing RecordSource?

  6. #6
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    Create a query:
    select field1, field2
    from table1 t
    inner join table2 l
    on l.id = t.id
    order by l.lupfield

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

Similar Threads

  1. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  2. Replies: 1
    Last Post: 10-25-2010, 04:34 PM
  3. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  4. Replies: 0
    Last Post: 12-16-2009, 01:14 PM
  5. Access 2003, sort order property of a form
    By Rick West in forum Forms
    Replies: 11
    Last Post: 09-17-2009, 08:28 PM

Tags for this Thread

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