Order by

  • Thread starter Thread starter dale
  • Start date Start date
D

dale

I have a subform with three fields on it. The subform is based on a
table. One of the fields is setup as a combo box and I have a query that
I use to populate the combo box. The query returns data based on the id
of the field in the table. I would like to have the subform ordered by
the value returned in the first fields combo box. How can this be
accomplished.

Dale Brown
 
If you base a form on a query rather than directly on the table you can order
by a field. I'm not sure what you mean by ordering the subform data based on
the value returned in the combo box. Do you want the order to change based
 
What I am trying to do is update a table in the subform. The data being
display is horse number and name, rider name, and order number. The
combo box for horse number and name is based on a horse id field in the
table. The rider name is based on a rider id in the table. I want the
subform to be ordered by the horse number. From what I understand if I
use a query to get the data I want I will not be able to update the
table directly like I can when using the table itself as the
recordsource. Let me know what you think.
 
Updating the table through the query is the same as updating the table
itself. Note that you will not see the subform records arranged in order
until you specifically save the record. You could put something like this
into the subform's After Insert event (there may be another place for it, but
this works):

Me.Requery
DoCmd.GoToRecord , , acNewRec

This code will rearrange the records after each new entry (assuming the form
is based on a query that is sorted by a field) and place the cursor in the
new record, but it may not be what you want. If so, that same code should
work in a command button on the subform.
 
Back
Top