Results 1 to 8 of 8

Thread: combo box (97)

  1. #1
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Mt. Olive, North Carolina, USA
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    combo box (97)

    Hi All - Is there a way to sort the combo box so it displays sorted in the window of a table without making the combo row source a query???The source table is sorted by still displays unsorted in combo box. Thanks. <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: combo box (97)

    I don't think so - it must be a query or an SQL string; the sort order of a table will be ignored. A stored query is more efficient because the query engine can optimize it, but sometimes it's more convenient to use an SQL string, in particular if you want to change the row source dynamically (using VBA code).

  3. #3
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Mt. Olive, North Carolina, USA
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: combo box (97)

    I found something that I think is alot better than creating a query. In the row source use select distinct [db].[field] from [db]; and magically the data appears in order. Thanks for your reply.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: combo box (97)

    What you're using is a SQL string, exactly as Hans suggested. However, that select string will not do anything about putting the items in any particular order. If they "magically" appear in the right order, it's because that is the order they occur in the table and for no other reason. If you want to control the order, use the ORDER BY clause of the SQL string.
    Charlotte

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: combo box (97)

    In my experience, SELECT DISTINCT returns records ordered by the fields in the order they (the fields) occur; it is equivalent to a Totals query with Group By on all fields. Of course, if you want any other sort order, you must set it explicitly.

  6. #6
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Mt. Olive, North Carolina, USA
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: combo box (97)

    Don't ask me how but I went back and un-sorted the table to see if it would act like you described, the sql code still sorted the combo box. Since I know nothing about SQL strings, I will make note of adding ORDER BY if I have problems. Thank you.

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: combo box (97)

    You can't "unsort" a table. Records in a table are either in the order in which they were entered or they are sorted on the primary key.
    Charlotte

  8. #8
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Mt. Olive, North Carolina, USA
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: combo box (97)

    Ok, I removed the sort and then they were listed by the order in which they were entered which was at random.

Posting Permissions

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