Order By question

B

Becky

hi

My table has 3 fields (DivID, DivName, DivCode). I made a query based on
the same three fields, sorted by DivName ascending.

My form is based on the query and has a combo box for DivID(0 width) and
DivName. As desired, the combo box displays its DivName records in alpha
order.

Here is my question. I thought I'd ditch the query and use the table as the
form's recored source, but I can't get the form's Order By property to work??
Whan I set it to Order By DivName, the combo still uses the tables original
order. Am I missing something?

Thanks
 
D

Douglas J. Steele

The form's OrderBy property has nothing to do with the sort order of the
records in the combo box.

Rather, you need to ensure that the combo box's RowSource is a query with
the appropriate ORDER BY clause.
 
R

Rick Brandt

Becky said:
hi

My table has 3 fields (DivID, DivName, DivCode). I made a query based on
the same three fields, sorted by DivName ascending.

My form is based on the query and has a combo box for DivID(0 width) and
DivName. As desired, the combo box displays its DivName records in alpha
order.

Here is my question. I thought I'd ditch the query and use the table as the
form's recored source, but I can't get the form's Order By property to work??
Whan I set it to Order By DivName, the combo still uses the tables original
order. Am I missing something?

Thanks

The RowSouce of your ComboBox has nothing at all to do with the RecordSource of
your form. You would never expect one to have an effect on the other.

In most cases they would be looking at completely separate tables.
 
R

Rick Brandt

Becky said:
Thanks Douglas and Rick for the timely reply. Actually, I made a mistake
when I posted my question. The records I want to use ORDER BY on are in a
textbox, not a combo box as I stated. The field is called DivName, but when
I set the continuous form's ORDER BY to DivName, the records still appear in
the order they are in the original table. Any possible explanation?

You also have to set OrderByOn to True. It is actually better to just bind the
form to a simple query that has the order by clause that you want.
 
F

fredg

Thanks Douglas and Rick for the timely reply. Actually, I made a mistake
when I posted my question. The records I want to use ORDER BY on are in a
textbox, not a combo box as I stated. The field is called DivName, but when
I set the continuous form's ORDER BY to DivName, the records still appear in
the order they are in the original table. Any possible explanation?

Thanks

How are you setting the form's Order By?
What do you actually do?

After you set the form's sort order to [DivName] did you set the
Form's OrderByOn = True by right-clicking on the form and selecting
Apply Filter/Sort?
 
B

Becky

Yes, that's it. I didn't know about the OrderByOn being set as well. Thanks
to Rick & fredg
 
Top